You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2026/09/15 16:44:10 UTC
[PR] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
eschutho opened a new pull request, #44316:
URL: https://github.com/apache/superset/pull/44316
### SUMMARY
`get_virtual_table_metadata()` (the entry point behind "Sync columns from source" / dataset metadata refresh, reachable via `POST /api/v1/dataset/<id>/refresh`) wraps `process_template()` in a narrow `except SupersetSyntaxErrorException` handler.
`BaseTemplateProcessor.process_template` (`superset/jinja_context.py`) has two separate try/except blocks:
- the **parse** step (`self.env.from_string(sql)`) wraps `TemplateSyntaxError`/`SecurityError`/`UndefinedError`/Unicode errors into `SupersetSyntaxErrorException`;
- the **render** step (`template.render(context)`) catches `UndefinedError` and, when the undefined reference *isn't* shaped like a function call, does a bare `raise` — letting the raw `jinja2.exceptions.UndefinedError` propagate unwrapped.
#### PROBLEM
A virtual dataset whose SQL uses an undefined variable in a non-call expression — e.g. `SELECT {{ nonexistent_var + 1 }}` (arithmetic, not `{{ nonexistent_var(...) }}`) — raises the raw `UndefinedError` during `render()`, hitting that render-path bare-`raise`. `UndefinedError` is not a subclass of `SupersetSyntaxErrorException`, so `get_virtual_table_metadata`'s handler doesn't catch it. It isn't softened by `RefreshDatasetCommand` either (that only catches `SupersetVirtualTableParseException`), nor by the `@transaction` `on_error` decorator (default `catches=(SQLAlchemyError,)`). Net effect: a completely raw, unhandled `jinja2.exceptions.UndefinedError` surfaces — instead of the graceful "log a warning and skip the refresh; the row is already persisted" treatment (`SupersetVirtualTableParseException`, see #38012) that the *parse-time* UndefinedError sibling case gets two lines below in the same function.
#### FIX
Add an `except UndefinedError as ex:` branch **before** the existing `except SupersetSyntaxErrorException` branch, raising `SupersetVirtualTableParseException` (already imported) — the same target exception the parse-time sibling raises, so `RefreshDatasetCommand` softens both identically. `UndefinedError` is already imported from `jinja2` in this file. The diff is surgical: one new branch plus a regression test.
This mirrors the precedent pattern from #42366 (explicit early `UndefinedError` branch ordered before a broader handler, in `models/helpers.py::get_rendered_sql`). It is a **distinct site/bug** from #42401 (open), which fixes a missing `TemplateError` in an `except` tuple across four methods in `superset/connectors/sqla/models.py` — different file, different bug class. No open PR touches `connectors/sqla/utils.py`.
### TESTING INSTRUCTIONS
New unit test `test_get_virtual_table_metadata_render_undefined_error` in `tests/unit_tests/connectors/sqla/utils_test.py` asserts a render-step `UndefinedError` is softened to `SupersetVirtualTableParseException`. Verified it fails on pre-fix code (raw `UndefinedError` propagates) and passes after the fix. Full `utils_test.py` (12 passed) and `models_test.py` (85 passed) green; `ruff`, `ruff format`, `mypy`, and `pylint` pass via pre-commit.
Manual: create a virtual dataset with SQL `SELECT {{ nonexistent_var + 1 }}`, then click "Sync columns from source" — refresh is softened gracefully instead of surfacing a raw `UndefinedError`.
### ADDITIONAL INFORMATION
- [ ] 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
🤖 Generated with [Claude Code](https://claude.com/claude-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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44316:
URL: https://github.com/apache/superset/pull/44316#issuecomment-5684248690
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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44316:
URL: https://github.com/apache/superset/pull/44316#issuecomment-5769836090
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 an incremental AI Review.
- `/review full` - 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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #44316:
URL: https://github.com/apache/superset/pull/44316#issuecomment-5684374788
@rebenitez1802 — routing this your way for review. 🦉
This is the render-time sibling of #44312 (and same bug-class as #44172 / #42366 / #42401): `get_virtual_table_metadata` only caught `SupersetSyntaxErrorException`, so a raw `jinja2.UndefinedError` re-raised from `process_template`'s **render** step (the non-function-call branch, `jinja_context.py`) escaped as an unhandled 500 on the "Sync columns from source" path. Fix adds an `except UndefinedError` branch that softens to `SupersetVirtualTableParseException`, matching the parse-time sibling. Since you already hold the #44312 context, bundling it here.
Heads-up on load: you're carrying the most active reviews on the roster right now (plus #44172 + #44312 in flight). If you'd rather I re-route this one, say the word and I'll hand it to Gabriel — no problem at all.
One CI note: several required checks are currently red (frontend `playwright`/`cypress` + the `test-postgres-required` gate), but they look unrelated to this backend-only diff — the underlying `test-postgres` matrix didn't run at this SHA. Worth confirming they go green before merge.
--
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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho closed pull request #44316: fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata
URL: https://github.com/apache/superset/pull/44316
--
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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #44316:
URL: https://github.com/apache/superset/pull/44316
--
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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44316:
URL: https://github.com/apache/superset/pull/44316#issuecomment-5721920357
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44316?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 73.71%. Comparing base ([`ae240a8`](https://app.codecov.io/gh/apache/superset/commit/ae240a8e6f0332acb709943d0884eae73927c9de?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`da06ce2`](https://app.codecov.io/gh/apache/superset/commit/da06ce20ceec3dbe777adaef0d699f52d83249ea?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 86 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44316 +/- ##
==========================================
- Coverage 75.91% 73.71% -2.20%
==========================================
Files 2926 2929 +3
Lines 173023 185176 +12153
Branches 40139 43171 +3032
==========================================
+ Hits 131349 136501 +5152
- Misses 38995 45738 +6743
- Partials 2679 2937 +258
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44316/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/44316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.30% <0.00%> (?)` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/44316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.19% <0.00%> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/44316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `71.94% <100.00%> (-4.21%)` | :arrow_down: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/44316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.14% <100.00%> (+<0.01%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/44316?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho closed pull request #44316: fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata
URL: https://github.com/apache/superset/pull/44316
--
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] fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho closed pull request #44316: fix(datasets): soften render-time UndefinedError in get_virtual_table_metadata
URL: https://github.com/apache/superset/pull/44316
--
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