3

My module is working as expected with the following settings, config and config export. But when I try to run tests, I get the following error. I'm not sure what is wrong.

Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for riddler.settings with the following errors: riddler.settings:riddles missing schema in Drupal\Core\Config\Testing\ConfigSchemaChecker->onConfigSave() (line 102 of /var/www/sb/sboss/docroot/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php).

# settings.yml
riddles:
 -
    question: 'Do you really hate Spam?'
    response: 'Yes!'
langcode: en


--------------------------------


#schema
riddler.settings:
  type: config_object
  riddles:
      question:
        type: label
        label: 'Question'
      response:
        type: label
        label: 'Response'


#config export

riddles:
 -
    question: 'Do you really hate Spam?'
    response: Yes!
  -
    question: 'What''s your favorite primary color?'
    response: 'blue, yellow, red'
1

I see several errors, not sure which one trips you: you missed a type for riddles and tried to define a mapping immediately under. But riddles is a sequence and each element in the sequence is that mapping. So:

riddler.settings:
  type: config_object
  mapping:
    riddles:
      type: sequence
      sequence:
        type: mapping
          question:
            type: label
            label: 'Question'
          response:
            type: label
            label: 'Response'

At least that's what I would attempt...

  • That gives me the following error: Drupal\Core\Config\UnsupportedDataTypeConfigException: Invalid data type in config riddler.settings: Unable to parse at line 8 (near " question:"). in Drupal\Core\Config\FileStorage->read() (line 106 of /var/www/sb/sboss/docroot/core/lib/Drupal/Core/Config/FileStorage.php). – awolfey Sep 23 '15 at 0:02
  • Thanks chx, that was very close and lead me to the solution. – awolfey Sep 23 '15 at 0:05
  • 1
    OH I left out the mapping: line although the space for it is visible, that's why question: is indented :) – user49 Sep 23 '15 at 0:15
1

Here's what worked.

riddler.settings:
  type: config_object
  mapping:
    riddles:
      type: sequence
      sequence:
        type: mapping
        mapping:
          question:
            type: label
            label: 'Question'
          response:
            type: label
            label: 'Response'

Thanks to chx for getting this most of the way there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.