Skip to content

chore: add paths to backend extension stack traces#37300

Merged
villebro merged 1 commit intoapache:masterfrom
villebro:ext-error-stack
Jan 21, 2026
Merged

chore: add paths to backend extension stack traces#37300
villebro merged 1 commit intoapache:masterfrom
villebro:ext-error-stack

Conversation

@villebro
Copy link
Member

@villebro villebro commented Jan 21, 2026

SUMMARY

Currently when backend extensions raise exceptions, they don't contain a reference to the actual file (notice File: "<string>" at the top of the stack):

Traceback (most recent call last):
  File "/Users/ville/projects/superset/superset/tasks/executor.py", line 108, in execute_task
    executor_fn(*args, **kwargs)
  File "<string>", line 36, in my_task
ZeroDivisionError: division by zero

This makes it difficult to track down where the error actually occurred.

In this PR, we propose stack traces will have a reference to the source file as follows:

  • For bundled supx extensions, the reference will be supx://<extension-id>/file.py. This URL-like format is due to the fact that the python file doesn't exist physically on the system (it's inside the bundle).
  • For local development extensions, the reference will be the pull path to the dist file: .../dist/.../file.py.

This will make stack traces more actionable, both when developing locally, and also when using bundles.

Local extension after changes:

Traceback (most recent call last):
  File "/Users/ville/projects/superset/superset/tasks/executor.py", line 108, in execute_task
    executor_fn(*args, **kwargs)
  File "/Users/ville/projects/superset-extensions/helloworld/dist/backend/src/helloworld/api.py", line 36, in my_task
    x = 120/0
ZeroDivisionError: division by zero

Notice that for local extensions, it's now showing the actual code x = 120/0 that raised the error to help narrow down the problematic code. This is thanks to the interpreter being able to read the file on the filesystem.

supx bundle after changes:

Traceback (most recent call last):
  File "/Users/ville/projects/superset/superset/tasks/executor.py", line 108, in execute_task
    executor_fn(*args, **kwargs)
  File "supx://helloworld/backend/src/helloworld/api.py", line 36, in my_task
ZeroDivisionError: division by zero

Here we're intentionally not showing the offending code, as we don't want to expose more of the internals than necessary (line number and method should be fine). We can add parity with local extensions for bundles, but IMO it's an unnecessary leak of extension internals, so I advise against it. It would also consume slightly more memory, as we'd have to load the supx code into linecache. While the memory overhead is arguably negligible, it's still unnecessary IMO. But I'm curious to hear how others feel about this.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codeant-ai-for-open-source
Copy link
Contributor

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 ·
Reddit ·
LinkedIn

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 21, 2026

Code Review Agent Run #b474c8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 3295dc1..3295dc1
    • superset/extensions/discovery.py
    • superset/extensions/types.py
    • superset/extensions/utils.py
    • superset/initialization/__init__.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the change:backend Requires changing the backend label Jan 21, 2026
@netlify
Copy link

netlify bot commented Jan 21, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3295dc1
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6970722b84f331000808f943
😎 Deploy Preview https://deploy-preview-37300--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines +37 to +39
source_base_path: (
str # Base path for traceback filenames (absolute path or supx:// URL)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Breaking change: adding source_base_path as a required dataclass field (no default) will cause existing code that constructs LoadedExtension without this new argument to raise a TypeError at runtime. Make the field optional or provide a default to preserve backward compatibility. [possible bug]

Severity Level: Critical 🚨
- ❌ Extension loading fails with TypeError during instantiation.
- ❌ Background tasks using extensions fail at startup/runtime.
- ⚠️ Backwards compatibility for third‑party extensions broken.
Suggested change
source_base_path: (
str # Base path for traceback filenames (absolute path or supx:// URL)
)
source_base_path: str = "" # Base path for traceback filenames (absolute path or supx:// URL)
Steps of Reproduction ✅
1. Open a Python REPL or run any process that imports the dataclass: `from
superset.extensions.types import LoadedExtension` (file:
`superset/extensions/types.py:30-39`).

2. Instantiate the dataclass with the pre-PR argument set used across the codebase, e.g.:

   `LoadedExtension(id="ext1", name="ext", manifest=..., frontend={}, backend={},
   version="1.0")`

   (this mirrors how LoadedExtension objects were constructed before adding the new
   field).

3. Observe Python raising a TypeError similar to:

   "TypeError: __init__() missing 1 required positional argument: 'source_base_path'"

   This is raised from the dataclass-generated __init__ defined by `LoadedExtension` (see
   `superset/extensions/types.py:30-39`).

4. Runtime effect: any code path that previously constructed LoadedExtension without the
new argument (e.g. extension registration/loader) will fail at instantiation time. Because
the PR description and stacktrace examples reference extension execution, this will
manifest when extensions are loaded or registered during startup or when tasks execute
(see `superset/tasks/executor.py:108` in PR description).
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/extensions/types.py
**Line:** 37:39
**Comment:**
	*Possible Bug: Breaking change: adding `source_base_path` as a required dataclass field (no default) will cause existing code that constructs `LoadedExtension` without this new argument to raise a TypeError at runtime. Make the field optional or provide a default to preserve backward compatibility.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue, as this feature is still in development

@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI finished reviewing your PR.

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.60%. Comparing base (3fba967) to head (3295dc1).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
superset/extensions/utils.py 0.00% 13 Missing ⚠️
superset/extensions/discovery.py 0.00% 10 Missing ⚠️
superset/extensions/types.py 0.00% 1 Missing ⚠️
superset/initialization/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #37300       +/-   ##
===========================================
+ Coverage        0   67.60%   +67.60%     
===========================================
  Files           0      644      +644     
  Lines           0    48309    +48309     
  Branches        0     5298     +5298     
===========================================
+ Hits            0    32661    +32661     
- Misses          0    14357    +14357     
- Partials        0     1291     +1291     
Flag Coverage Δ
hive 42.68% <0.00%> (?)
mysql 65.64% <0.00%> (?)
postgres 65.68% <0.00%> (?)
presto 46.27% <0.00%> (?)
python 67.57% <0.00%> (?)
sqlite 65.41% <0.00%> (?)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@villebro villebro merged commit 281c0c9 into apache:master Jan 21, 2026
92 of 93 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Superset Extensions Jan 21, 2026
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend size/M

Projects

Development

Successfully merging this pull request may close these issues.

2 participants