You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/01/21 23:11:08 UTC

[PR] feat(docs): add auto-generated troubleshooting section to database pages [superset]

rusackas opened a new pull request, #37345:
URL: https://github.com/apache/superset/pull/37345

   ### SUMMARY
   This PR extracts `custom_errors` from database engine specs and displays them in a new "Troubleshooting" section on each database's documentation page. This provides zero-maintenance troubleshooting documentation that stays in sync with the actual error handling code.
   
   **Key features:**
   - Errors grouped by category (Authentication, Connection, Query, Permissions, etc.)
   - Human-readable error messages with solution hints
   - Links to related issue codes
   - Invalid field indicators to help users know what to check
   
   Currently extracts **73 custom errors** across **18 databases** including:
   - PostgreSQL (9 errors)
   - MySQL (5 errors) 
   - BigQuery (5 errors)
   - Presto/Trino (8 errors)
   - Denodo (10 errors)
   - And more...
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before:** Database pages had no troubleshooting information
   
   **After:** Each database page that has `custom_errors` defined in its engine spec now shows a collapsible "Troubleshooting" section with categorized error messages:
   
   ```
   ๐Ÿ› Troubleshooting
   โ”œโ”€โ”€ Authentication (2 errors)
   โ”‚   โ”œโ”€โ”€ Invalid username: 'The username "%(username)s" does not exist.'
   โ”‚   โ”‚   Check these fields: [username]
   โ”‚   โ”‚   Related: Issue 1012
   โ”‚   โ””โ”€โ”€ Invalid password: 'The password provided for username "%(username)s" is incorrect.'
   โ”‚       Check these fields: [username, password]
   โ”‚       Related: Issue 1013
   โ”œโ”€โ”€ Connection (3 errors)
   โ”‚   โ””โ”€โ”€ ...
   โ””โ”€โ”€ Query (4 errors)
       โ””โ”€โ”€ ...
   ```
   
   ### TESTING INSTRUCTIONS
   1. Build docs locally: `cd docs && npm run build`
   2. Start local preview: `npm run serve`
   3. Navigate to a database page with custom errors (e.g., PostgreSQL, MySQL, BigQuery)
   4. Scroll down to verify the "Troubleshooting" section appears with categorized errors
   5. Click on error categories to expand and see the error details
   6. Verify issue code links point to the correct anchor
   
   ### ADDITIONAL INFORMATION
   
   **Files changed:**
   - `docs/scripts/extract_custom_errors.py` - New Python script to parse custom_errors from engine specs
   - `docs/scripts/generate-database-docs.mjs` - Integrates custom_errors extraction into docs generation
   - `docs/src/components/databases/types.ts` - Adds CustomError interface
   - `docs/src/components/databases/DatabasePage.tsx` - Renders the Troubleshooting section
   - `docs/src/data/databases.json` - Updated with custom_errors data
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ๐Ÿค– Generated with [Claude Code](https://claude.ai/code)


-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   ## **Sequence Diagram**
   
   The PR adds a pipeline that extracts custom_errors from database engine spec files and merges them into the generated databases documentation; the frontend then renders a "Troubleshooting" section from that data. The diagram shows the core success path from extraction to rendering.
   
   ```mermaid
   sequenceDiagram
       participant DocGen as generate-database-docs.mjs
       participant Extractor as extract_custom_errors.py
       participant Specs as db_engine_specs (Python)
       participant Data as databases.json
       participant Frontend as DatabasePage.tsx
   
       DocGen->>Extractor: Run extractor script (python)
       Extractor->>Specs: Parse engine spec files for custom_errors
       Specs-->>Extractor: Return extracted custom_errors JSON
       Extractor-->>DocGen: Print JSON (stdout)
       DocGen->>Data: Merge custom_errors into per-database docs
       Frontend->>Data: Load generated databases.json
       Frontend->>Frontend: RenderTroubleshooting() using docs.custom_errors
   ```
   
   ---
   *Generated by [CodeAnt AI](https://codeant.ai)*
   


-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   **Bito Automatic Review Skipped โ€“ PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   ## **Sequence Diagram**
   
   Shows how custom_errors are extracted from engine specs, merged into generated database docs, and surfaced in the UI as an "Errors" tag and a Troubleshooting section on each database page.
   
   ```mermaid
   sequenceDiagram
       participant CI / Dev as Docs Generator
       participant Extractor as extract_custom_errors.py
       participant DatabasesJSON as databases.json
       participant DocsUI as Frontend (DatabaseIndex / DatabasePage)
       participant User
   
       Docs Generator->>Extractor: Run extraction script (python) to parse engine specs
       Extractor-->>Docs Generator: JSON map of module -> custom_errors
       Docs Generator->>DatabasesJSON: Merge custom_errors into each DB doc entry
       DocsUI->>DatabasesJSON: Load generated databases data (with custom_errors)
       DocsUI-->>User: Show "Errors" tag (count) in index and render Troubleshooting section on DB page
   ```
   
   ---
   *Generated by [CodeAnt AI](https://codeant.ai)*
   


-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #37345:
URL: https://github.com/apache/superset/pull/37345


-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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


##########
docs/scripts/extract_custom_errors.py:
##########
@@ -0,0 +1,296 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Extract custom_errors from database engine specs for documentation.
+
+This script parses engine spec files to extract error handling information
+that can be displayed on database documentation pages.
+
+Usage: python scripts/extract_custom_errors.py
+Output: JSON mapping of engine spec module names to their custom errors
+"""
+
+import ast
+import json  # noqa: TID251 - standalone docs script, not part of superset
+import sys
+from pathlib import Path
+from typing import Any
+
+# Map SupersetErrorType values to human-readable categories and issue codes
+ERROR_TYPE_INFO = {
+    "CONNECTION_INVALID_USERNAME_ERROR": {
+        "category": "Authentication",
+        "description": "Invalid username",
+        "issue_codes": [1012],
+    },
+    "CONNECTION_INVALID_PASSWORD_ERROR": {
+        "category": "Authentication",
+        "description": "Invalid password",
+        "issue_codes": [1013],
+    },
+    "CONNECTION_ACCESS_DENIED_ERROR": {
+        "category": "Authentication",
+        "description": "Access denied",
+        "issue_codes": [1014, 1015],
+    },
+    "CONNECTION_INVALID_HOSTNAME_ERROR": {
+        "category": "Connection",
+        "description": "Invalid hostname",
+        "issue_codes": [1007],
+    },
+    "CONNECTION_PORT_CLOSED_ERROR": {
+        "category": "Connection",
+        "description": "Port closed or refused",
+        "issue_codes": [1008],
+    },
+    "CONNECTION_HOST_DOWN_ERROR": {
+        "category": "Connection",
+        "description": "Host unreachable",
+        "issue_codes": [1009],
+    },
+    "CONNECTION_UNKNOWN_DATABASE_ERROR": {
+        "category": "Connection",
+        "description": "Unknown database",
+        "issue_codes": [1015],
+    },
+    "CONNECTION_DATABASE_PERMISSIONS_ERROR": {
+        "category": "Permissions",
+        "description": "Insufficient permissions",
+        "issue_codes": [1017],
+    },
+    "CONNECTION_MISSING_PARAMETERS_ERROR": {
+        "category": "Configuration",
+        "description": "Missing parameters",
+        "issue_codes": [1018],
+    },
+    "CONNECTION_DATABASE_TIMEOUT": {
+        "category": "Connection",
+        "description": "Connection timeout",
+        "issue_codes": [1001, 1009],
+    },
+    "COLUMN_DOES_NOT_EXIST_ERROR": {
+        "category": "Query",
+        "description": "Column not found",
+        "issue_codes": [1003, 1004],
+    },
+    "TABLE_DOES_NOT_EXIST_ERROR": {
+        "category": "Query",
+        "description": "Table not found",
+        "issue_codes": [1003, 1005],
+    },
+    "SCHEMA_DOES_NOT_EXIST_ERROR": {
+        "category": "Query",
+        "description": "Schema not found",
+        "issue_codes": [1003, 1016],
+    },
+    "SYNTAX_ERROR": {
+        "category": "Query",
+        "description": "SQL syntax error",
+        "issue_codes": [1030],
+    },
+    "OBJECT_DOES_NOT_EXIST_ERROR": {
+        "category": "Query",
+        "description": "Object not found",
+        "issue_codes": [1029],
+    },
+    "GENERIC_DB_ENGINE_ERROR": {
+        "category": "General",
+        "description": "Database engine error",
+        "issue_codes": [1002],
+    },
+}
+
+
+def extract_string_from_call(node: ast.Call) -> str | None:
+    """Extract string from __() or _() translation calls."""
+    if not node.args:
+        return None
+    arg = node.args[0]
+    if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
+        return arg.value
+    elif isinstance(arg, ast.JoinedStr):
+        # f-string - try to reconstruct
+        parts = []
+        for value in arg.values:
+            if isinstance(value, ast.Constant):
+                parts.append(str(value.value))
+            elif isinstance(value, ast.FormattedValue):
+                # Just use a placeholder
+                parts.append("{...}")
+        return "".join(parts)
+    return None
+
+
+def extract_custom_errors_from_file(filepath: Path) -> dict[str, list[dict[str, Any]]]:
+    """
+    Extract custom_errors definitions from a Python engine spec file.
+
+    Returns a dict mapping class names to their custom errors list.
+    """
+    results = {}
+
+    try:
+        with open(filepath, "r", encoding="utf-8") as f:
+            source = f.read()
+
+        tree = ast.parse(source)
+
+        for node in ast.walk(tree):
+            if isinstance(node, ast.ClassDef):
+                class_name = node.name
+
+                for item in node.body:
+                    # Look for custom_errors = { ... }
+                    if (
+                        isinstance(item, ast.AnnAssign)
+                        and isinstance(item.target, ast.Name)
+                        and item.target.id == "custom_errors"
+                        and isinstance(item.value, ast.Dict)
+                    ):
+                        errors = extract_errors_from_dict(item.value, source)
+                        if errors:
+                            results[class_name] = errors
+
+                    # Also handle simple assignment: custom_errors = { ... }
+                    elif (
+                        isinstance(item, ast.Assign)
+                        and len(item.targets) == 1
+                        and isinstance(item.targets[0], ast.Name)
+                        and item.targets[0].id == "custom_errors"
+                        and isinstance(item.value, ast.Dict)
+                    ):
+                        errors = extract_errors_from_dict(item.value, source)
+                        if errors:
+                            results[class_name] = errors
+
+    except Exception as e:
+        print(f"Error parsing {filepath}: {e}", file=sys.stderr)
+
+    return results

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Avoid catching blind Exception</b></div>
   <div id="fix">
   
   Replace the broad `Exception` catch with specific exception types (e.g., `OSError`, `SyntaxError`, `ValueError`) to handle only expected errors.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
                           if errors:
                               results[class_name] = errors
    
       except (OSError, SyntaxError, ValueError) as e:
           print(f"Error parsing {filepath}: {e}", file=sys.stderr)
    
       return results
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #179764</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   CodeAnt AI finished reviewing your 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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   ### <span aria-hidden="true">โœ…</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">๐Ÿ”จ</span> Latest commit | d1a01b597095c37f964f59e569162fe8d69d32db |
   |<span aria-hidden="true">๐Ÿ”</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/697168c7de394f0008d34a83 |
   |<span aria-hidden="true">๐Ÿ˜Ž</span> Deploy Preview | [https://deploy-preview-37345--superset-docs-preview.netlify.app](https://deploy-preview-37345--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.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM3MzQ1LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.2MDnhWzFPCIlAcSlEzFiWbct5it43N0yBg0IWX_usfs)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-37345--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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   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] feat(docs): add auto-generated troubleshooting section to database pages [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 #37345:
URL: https://github.com/apache/superset/pull/37345#discussion_r2714677644


##########
docs/scripts/generate-database-docs.mjs:
##########
@@ -675,6 +675,75 @@ function updateReadme(databases) {
   return false;
 }
 
+/**
+ * Extract custom_errors from engine specs for troubleshooting documentation
+ * Returns a map of module names to their custom errors
+ */
+function extractCustomErrors() {
+  console.log('Extracting custom_errors from engine specs...');
+
+  try {
+    const scriptPath = path.join(__dirname, 'extract_custom_errors.py');
+    const result = spawnSync('python3', [scriptPath], {
+      cwd: ROOT_DIR,
+      encoding: 'utf-8',
+      timeout: 30000,
+      maxBuffer: 10 * 1024 * 1024,
+    });
+
+    if (result.error) {
+      throw result.error;
+    }
+    if (result.status !== 0) {
+      throw new Error(result.stderr || 'Python script failed');
+    }
+
+    const customErrors = JSON.parse(result.stdout);
+    const moduleCount = Object.keys(customErrors).length;
+    const errorCount = Object.values(customErrors).reduce((sum, classes) =>
+      sum + Object.values(classes).reduce((s, errs) => s + errs.length, 0), 0);
+    console.log(`  Found ${errorCount} custom errors across ${moduleCount} modules`);
+    return customErrors;
+  } catch (err) {
+    console.log('  Could not extract custom_errors:', err.message);
+    return null;
+  }
+}
+
+/**
+ * Merge custom_errors into database documentation
+ * Maps by module name since that's how both datasets are keyed
+ */
+function mergeCustomErrors(databases, customErrors) {
+  if (!customErrors) return;
+
+  let mergedCount = 0;
+
+  for (const [, db] of Object.entries(databases)) {
+    const moduleName = db.module;
+    if (!moduleName || !customErrors[moduleName]) continue;
+

Review Comment:
   **Suggestion:** When docs are generated via the full Flask context, `db.module` contains the full Python module path (for example, `superset.db_engine_specs.postgres`), but `extract_custom_errors.py` keys its results by the file stem (for example, `postgres`), so indexing `customErrors[moduleName]` fails and `custom_errors` are never merged, causing the Troubleshooting section to be empty in that mode; normalize the module name to its last segment before doing the lookup so both data sources line up. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Critical ๐Ÿšจ</summary>
   
   ```mdx
   - โŒ Troubleshooting section empty for Flask-mode docs.
   - โš ๏ธ Developers miss synced error guidance.
   - โš ๏ธ Docs preview doesn't reflect runtime error handling.
   ```
   </details>
   
   ```suggestion
       if (!moduleName) continue;
   
       // Normalize module name to match extract_custom_errors.py keys (basename)
       const moduleKey = moduleName.split('.').pop();
       if (!moduleKey || !customErrors[moduleKey]) continue;
   
       // Get all errors from all classes in this module
       const moduleErrors = customErrors[moduleKey];
   ```
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. Run the docs generator in an environment where Flask context is available so the script
   chooses the full-run path: see tryRunFullScript() invocation at
   docs/scripts/generate-database-docs.mjs:818 which assigns `databases =
   tryRunFullScript();` (file: docs/scripts/generate-database-docs.mjs, line ~818). The
   variable `databases` is therefore populated from the Flask-derived YAML/docs.
   
   2. The script then calls extractCustomErrors() at
   docs/scripts/generate-database-docs.mjs:841 which invokes the Python extractor (file:
   extract_custom_errors.py) and returns a map keyed by file stem (e.g., "postgres").
   Confirmed call site: docs/scripts/generate-database-docs.mjs:841.
   
   3. The merge loop at docs/scripts/generate-database-docs.mjs:722 iterates databases and
   reads module name from each db object via `const moduleName = db.module;` (file:
   docs/scripts/generate-database-docs.mjs, line 722). When databases were produced by the
   Flask path, db.module contains the full Python module path (e.g.,
   "superset.db_engine_specs.postgres").
   
   4. The current code does lookup using `customErrors[moduleName]`
   (docs/scripts/generate-database-docs.mjs:723-724). Because the extractor keys are file
   stems like "postgres", the property lookup fails (no match) and the loop continues without
   merging. The result: db.documentation.custom_errors is not set and the Troubleshooting
   section remains empty for pages generated in Flask mode.
   
   5. Reproduce locally: run docs/scripts/generate-database-docs.mjs in an environment where
   tryRunFullScript() succeeds (a development Superset install). Observe console logs:
   tryRunFullScript returns databases (line ~818) and then "Merged custom_errors" log never
   appears because mergeCustomErrors() finds no matches (loop at line 722). Inspect one
   generated database JSON entry in docs/src/data/databases.json: its documentation lacks
   custom_errors.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** docs/scripts/generate-database-docs.mjs
   **Line:** 724:725
   **Comment:**
   	*Logic Error: When docs are generated via the full Flask context, `db.module` contains the full Python module path (for example, `superset.db_engine_specs.postgres`), but `extract_custom_errors.py` keys its results by the file stem (for example, `postgres`), so indexing `customErrors[moduleName]` fails and `custom_errors` are never merged, causing the Troubleshooting section to be empty in that mode; normalize the module name to its last segment before doing the lookup so both data sources line up.
   
   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>



-- 
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] feat(docs): add auto-generated troubleshooting section to database pages [superset]

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

   CodeAnt AI is reviewing your PR.
   
   ---
   
   ### Thanks for using CodeAnt! ๐ŸŽ‰
   
   We're free for open-source projects. if you're enjoying it, help us grow by sharing.
   
   [Share on X](https://twitter.com/intent/tweet?text=Just%20tried%20%40CodeAntAI%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A&url=https%3A//codeant.ai) ยท
   [Reddit](https://www.reddit.com/submit?title=Check%20out%20CodeAnt%20for%20automated%20code%20review&text=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos.%20Worth%20checking%20out%3A%20https%3A//codeant.ai) ยท
   [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcodeant.ai&mini=true&title=Check%20out%20CodeAnt%20for%20automated%20code%20review&summary=Just%20tried%20CodeAnt%20for%20automated%20code%20review%20and%20I%27m%20impressed%21%20Free%20for%20open%20source%20with%20a%20free%20trial%20for%20private%20repos)
   


-- 
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