ai.provider_config schema has invalid mapping definition for configuration key
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3580948. --> Reported by: [svendecabooter](https://www.drupal.org/user/35369) Related to !1340 >>> <p>[Tracker]<br> <strong>Update Summary: </strong>[One-line status update for stakeholders]<br> <strong>Short Description: </strong>[One-line issue summary for stakeholders]<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> <em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The `ai.provider_config` schema type introduced in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3552774" title="Status: Closed (fixed)">#3552774: Create linkable schema for providers</a></span> has an invalid definition for the `configuration` key. The current schema in `config/schema/ai.provider_config.schema.yml` is:</p> <pre>configuration:<br>&nbsp; type: mapping<br>&nbsp; label: 'Provider Configuration'<br>&nbsp; nullable: true<br>&nbsp; mapping:<br>&nbsp;&nbsp;&nbsp; type: ignore</pre><p>This is invalid because when <code>type: mapping</code> is used, the <code>mapping: </code> key must contain named property definitions, not a type: declaration. Drupal's config schema system interprets <code>mapping: type: ignore</code> as a mapping with a literal key called <code>type</code> whose value is <code>ignore</code> &mdash; which is not the intent.</p> <h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4> <p>1. Create a module with a config schema that references `type: ai.provider_config`:</p> <pre># config/schema/my_module.schema.yml<br>my_module.settings:<br>&nbsp; type: config_object<br>&nbsp; label: 'My module settings'<br>&nbsp; mapping:<br>&nbsp;&nbsp;&nbsp; provider_config:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: ai.provider_config<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; label: 'AI Provider Configuration'</pre><p>2. Add a default config file:</p> <pre># config/install/my_module.settings.yml<br>provider_config:<br>&nbsp; use_default: true<br>&nbsp; provider_id: ''<br>&nbsp; model_id: ''<br>&nbsp; configuration: {}</pre><p>3. Enable the module: <code>drush en my_module</code><br> 4. Observe the error:<br> <code>The mapping definition at `my_module.settings.provider_config:configuration` is invalid: its `type` key contains a string. It must be an array.</code></p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Change the `configuration` key from `type: mapping` with an invalid nested `mapping:` to `type: ignore`, since the provider configuration values are arbitrary key-value pairs that vary per provider:</p> <pre>configuration:<br>&nbsp; type: ignore<br>&nbsp; label: 'Provider Configuration'<br>&nbsp; nullable: true</pre><h3 id="summary-ai-usage">AI usage (if applicable)</h3> <p>[ x ] AI Assisted Issue<br> This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
issue