You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "michael-s-molina (via GitHub)" <gi...@apache.org> on 2026/02/10 18:25:02 UTC

[PR] refactor: Make extensions contribution schema consistent [superset]

michael-s-molina opened a new pull request, #37856:
URL: https://github.com/apache/superset/pull/37856

   ### SUMMARY
   
   Refactors the extension contribution schema to use a consistent nested structure for views and menus.
   
   **Problem:**
   The contribution schema had an inconsistency where `views` and `menus` used dot-notation string keys like `"sqllab.panels"` or `"sqllab.editor"` instead of a properly nested object structure.
   
   **Solution:**
   Changed to a fully nested structure where scope and location are separate object levels:
   
   ```json
   // Before (dot-notation keys)
   {
     "views": {
       "sqllab.panels": [...]
     },
     "menus": {
       "sqllab.editor": {...}
     }
   }
   
   // After (nested structure)
   {
     "views": {
       "sqllab": {
         "panels": [...]
       }
     },
     "menus": {
       "sqllab": {
         "editor": {...}
       }
     }
   }
   ```
   
   **Changes:**
   
   1. **TypeScript Types** (`contributions.ts`):
      - Added `SqlLabLocation` type with valid locations
      - Updated `ViewContributions` and `MenuContributions` to use nested structure
      - Type-safe: only valid scopes (`sqllab`) and locations (`leftSidebar`, `rightSidebar`, `panels`, `editor`, `statusBar`, `results`, `queryHistory`) are allowed
   
   2. **View Locations** (`SqlLab/contributions.ts`):
      - Renamed `ViewContribution` enum to `ViewLocations` const object
      - Nested structure: `ViewLocations.sqllab.panels` instead of `ViewContribution.Panels`
   
   3. **ExtensionsManager**:
      - Updated `getViewContributions()` and `getMenuContributions()` to handle nested lookup
      - Splits key on `.` to access `scope[location]`
   
   4. **Pydantic Schema** (`types.py`):
      - Updated `ContributionConfig` to use nested dict structure
   
   5. **Component Updates** (8 files):
      - Updated all SQL Lab components to use new `ViewLocations.sqllab.*` pattern
   
   6. **Documentation** (4 files):
      - Updated all extension.json examples in developer portal docs
   
   ### TESTING INSTRUCTIONS
   
   Test with an extension that uses the new schema:
      - Update an extension's `extension.json` to use nested structure
      - Build and load the extension
      - Verify views and menus appear correctly in SQL Lab
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] refactor: Make extensions contribution schema consistent [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #37856:
URL: https://github.com/apache/superset/pull/37856#issuecomment-3879950147

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] refactor: Make extensions contribution schema consistent [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina merged PR #37856:
URL: https://github.com/apache/superset/pull/37856


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] refactor: Make extensions contribution schema consistent [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #37856:
URL: https://github.com/apache/superset/pull/37856#discussion_r2789577895


##########
superset-core/src/superset_core/extensions/types.py:
##########
@@ -56,19 +56,37 @@ class ModuleFederationConfig(BaseModel):
 
 
 class ContributionConfig(BaseModel):
-    """Configuration for frontend UI contributions."""
+    """Configuration for frontend UI contributions.
+
+    Views and menus use a nested structure: type -> scope -> location -> contributions.
+
+    Example:
+        {
+            "views": {
+                "sqllab": {
+                    "panels": [{"id": "my-ext.panel", "name": "My Panel"}],
+                    "leftSidebar": [{"id": "my-ext.sidebar", "name": "Sidebar"}]
+                }
+            },
+            "menus": {
+                "sqllab": {
+                    "editor": {"primary": [...], "secondary": [...]}
+                }
+            }
+        }
+    """
 
     commands: list[dict[str, Any]] = Field(
         default_factory=list,
         description="Command contributions",
     )
-    views: dict[str, list[dict[str, Any]]] = Field(
+    views: dict[str, dict[str, list[dict[str, Any]]]] = Field(

Review Comment:
   **Suggestion:** The `views` field type was tightened from a flat mapping to a doubly nested mapping, which will cause Pydantic validation failures for any existing extensions that still use the documented legacy `"sqllab.panels": [...]` dot-notation format; unlike `menus`, which still accepts the old shape, `views` can no longer deserialize those manifests. Relaxing the type to a simple dict preserves compatibility with both the old flat keys and the new nested shape while still allowing the frontend to interpret the structure correctly. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Legacy extensions with flat views fail schema validation.
   - ⚠️ Affected extensions cannot load frontend contributions.
   - ⚠️ Menus remain compatible while views break asymmetrically.
   ```
   </details>
   
   ```suggestion
       views: dict[str, Any] = Field(
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Create an extension configuration file `extension.json` with a legacy flat views shape
   as documented before this refactor, for example:
   
      ```json
   
      {
   
        "frontend": {
   
          "contributions": {
   
            "views": {
   
              "sqllab.panels": [
   
                { "id": "my-ext.panel", "name": "My Panel" }
   
              ]
   
            },
   
            "menus": {
   
              "sqllab.editor": {
   
                "primary": []
   
              }
   
            }
   
          }
   
        }
   
      }
   
      ```
   
   2. The Superset backend (or build tool) loads `extension.json` and validates it against
   `ExtensionConfig` in `superset-core/src/superset_core/extensions/types.py`, where
   `ExtensionConfigFrontend.contributions` is a `ContributionConfig` instance (see
   `ExtensionConfigFrontend` in this file).
   
   3. During Pydantic validation of `ContributionConfig` at `views` (lines 83–86), Pydantic
   attempts to coerce the `views` object into `dict[str, dict[str, list[dict[str, Any]]]]`.
   The key `"sqllab.panels"` maps to a list, not to a nested dict, so the value type does not
   match the expected `dict[str, list[dict[str, Any]]]`.
   
   4. Pydantic raises a `ValidationError` for the `views` field while the `menus` field
   passes validation (its type `dict[str, dict[str, Any]]` is still compatible with the
   legacy `"sqllab.editor": {...}` shape), causing the extension configuration (and therefore
   that extension) to fail to load/validate using the current schema.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-core/src/superset_core/extensions/types.py
   **Line:** 83:83
   **Comment:**
   	*Logic Error: The `views` field type was tightened from a flat mapping to a doubly nested mapping, which will cause Pydantic validation failures for any existing extensions that still use the documented legacy `"sqllab.panels": [...]` dot-notation format; unlike `menus`, which still accepts the old shape, `views` can no longer deserialize those manifests. Relaxing the type to a simple dict preserves compatibility with both the old flat keys and the new nested shape while still allowing the frontend to interpret the structure correctly.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37856&comment_hash=5a52f8da4ec28cf2b8972b18e473c2fb13b10024d1dd0a15ef74ab4d7d7d8b26&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37856&comment_hash=5a52f8da4ec28cf2b8972b18e473c2fb13b10024d1dd0a15ef74ab4d7d7d8b26&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] refactor: Make extensions contribution schema consistent [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #37856:
URL: https://github.com/apache/superset/pull/37856#issuecomment-3879959035

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 637f1ccc2bed11acb14ff5ad2fdba5ac09ff9a4f |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/698b780115f9f50008a33a62 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-37856--superset-docs-preview.netlify.app](https://deploy-preview-37856--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM3ODU2LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.qO69Os3FCL45_tJlsQu5BkMD8gR0qTrFyBEwZRXbfVc)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-37856--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] refactor: Make extensions contribution schema consistent [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #37856:
URL: https://github.com/apache/superset/pull/37856#discussion_r2789612967


##########
superset-core/src/superset_core/extensions/types.py:
##########
@@ -56,19 +56,37 @@ class ModuleFederationConfig(BaseModel):
 
 
 class ContributionConfig(BaseModel):
-    """Configuration for frontend UI contributions."""
+    """Configuration for frontend UI contributions.
+
+    Views and menus use a nested structure: type -> scope -> location -> contributions.
+
+    Example:
+        {
+            "views": {
+                "sqllab": {
+                    "panels": [{"id": "my-ext.panel", "name": "My Panel"}],
+                    "leftSidebar": [{"id": "my-ext.sidebar", "name": "Sidebar"}]
+                }
+            },
+            "menus": {
+                "sqllab": {
+                    "editor": {"primary": [...], "secondary": [...]}
+                }
+            }
+        }
+    """
 
     commands: list[dict[str, Any]] = Field(
         default_factory=list,
         description="Command contributions",
     )
-    views: dict[str, list[dict[str, Any]]] = Field(
+    views: dict[str, dict[str, list[dict[str, Any]]]] = Field(

Review Comment:
   Not applicable as a breaking change is intended.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org