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/25 15:16:32 UTC
[PR] fix(import): downgrade expected validation-failure logs from error to warning [superset]
eschutho opened a new pull request, #44655:
URL: https://github.com/apache/superset/pull/44655
### SUMMARY
Chart, dashboard, database, dataset and saved-query imports log expected, user-input validation failures at `ERROR`. This PR changes those five log calls to `WARNING`. It only changes log levels. The exception, HTTP status and response body stay the same.
**Root cause**
`ImportModelsCommand.validate()` (`superset/commands/importers/v1/__init__.py`) calls `load_configs()` (`superset/commands/importers/v1/utils.py`), which validates each uploaded YAML file against its marshmallow schema. Every per-file failure (missing required field, invalid UUID, invalid `masked_encrypted_extra` JSON, a key read before schema validation, or "already exists and `overwrite=true` was not passed") is added to an `exceptions` list and raised as a single `CommandInvalidError`. Five `logger.error(...)` calls on that path log each failure along the way:
| File | Function | Message |
|---|---|---|
| `importers/v1/__init__.py` | `validate()` | `Validation failed for %s: %s` |
| `importers/v1/__init__.py` | `validate()` (fallback branch) | `Import validation error: %s` |
| `importers/v1/utils.py` | `load_configs()` | `Schema validation failed for %s (prefix: %s): %s` |
| `importers/v1/utils.py` | `load_configs()` | `Invalid JSON in masked_encrypted_extra for %s: %s` |
| `importers/v1/utils.py` | `load_configs()` | `Missing required key %s in config for %s (prefix: %s)` |
These are expected, client-caused conditions that already get a correct 4xx response. Tools that capture `ERROR` logs (such as error-tracking logging integrations) report each one as an application error. The messages include the uploaded file name, so the same underlying condition splits into many small, look-alike error issues. That hides the real volume and clutters error queues with items no one can act on.
**Why a log-level change is enough (the response is already correct)**
- `CommandInvalidError.status = 422` (`superset/commands/exceptions.py`).
- The `import_` endpoints (`superset/{dashboards,charts,databases,datasets}/api.py`, `superset/queries/saved_queries/api.py`, `superset/importexport/api.py`) call `command.run()` with no `try/except` around it and no `@safe` decorator. `@safe` would turn the error into a generic 500; see the `requires_json` docstring in `superset/views/base_api.py`.
- The dashboard version dispatcher (`superset/commands/dashboard/importers/dispatcher.py`) re-raises `CommandInvalidError`/`ValidationError` unchanged.
- The app-level `@app.errorhandler(CommandException)` in `superset/views/error_handling.py` renders the error with `status=ex.status`, which is 422, and already logs the exception at `WARNING` with its traceback.
- `ImportAssetsCommand` calls the same `load_configs()`, so `/api/v1/assets/import/` is covered too.
So the log severity was the only thing wrong.
**Tradeoffs**
None in practice. There's no change in behavior or response. The messages are still written to application logs at `WARNING`, so they remain available for support and debugging; they just stop being reported as errors. The two unrelated `logger.error` calls in `utils.py` that handle tag association (`Error parsing tags.yaml`, `Error processing tag ...`) cover genuinely unexpected failures and stay at `ERROR`.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (backend logging only).
### TESTING INSTRUCTIONS
Automated:
```bash
pytest tests/unit_tests/commands/importers/v1/
```
- New tests assert with `caplog` that each of the five messages is logged at `WARNING` and that nothing is logged at `ERROR` or above:
- `tests/unit_tests/commands/importers/v1/import_models_test.py` (new): both branches of `ImportModelsCommand.validate()`, and a check that the error has `status == 422`.
- `tests/unit_tests/commands/importers/v1/utils_test.py`: schema validation (missing required field), a key read before schema validation, and the existing invalid-`masked_encrypted_extra`-JSON test.
- Before the fix, exactly those 5 tests fail (each captures the message at `ERROR`). After it, `tests/unit_tests/commands/importers/v1/` gives **70 passed**.
- A wider run across the importer, dashboard, chart, database and dataset command unit tests gave 256 passed and 1 failed. The failure, `test_import_database_no_creds`, fails the same way without this change because the `bigquery` SQLAlchemy dialect isn't installed in the local environment.
Manual:
1. Export a chart, then remove `dataset_uuid` from its YAML and re-zip it.
2. `POST /api/v1/chart/import/` with the zip.
3. The response is still a 422 with the same body. The server log shows `WARNING ... Schema validation failed for charts/...` where it used to show `ERROR`.
### 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(import): downgrade expected validation-failure logs from error to warning [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44655:
URL: https://github.com/apache/superset/pull/44655#issuecomment-5835093364
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44655?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `40.00000%` with `3 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 66.06%. Comparing base ([`a44ab4d`](https://app.codecov.io/gh/apache/superset/commit/a44ab4d9281103c646ccf1d44d29db61154947c2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`aa92f20`](https://app.codecov.io/gh/apache/superset/commit/aa92f20964c4d78976e81ebdf5d505f431df12a8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 2 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/44655?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/commands/importers/v1/utils.py](https://app.codecov.io/gh/apache/superset/pull/44655?src=pr&el=tree&filepath=superset%2Fcommands%2Fimporters%2Fv1%2Futils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvaW1wb3J0ZXJzL3YxL3V0aWxzLnB5) | 33.33% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44655?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/commands/importers/v1/\_\_init\_\_.py](https://app.codecov.io/gh/apache/superset/pull/44655?src=pr&el=tree&filepath=superset%2Fcommands%2Fimporters%2Fv1%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvaW1wb3J0ZXJzL3YxL19faW5pdF9fLnB5) | 50.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44655?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44655 +/- ##
===========================================
- Coverage 81.11% 66.06% -15.05%
===========================================
Files 2955 2955
Lines 178336 178336
Branches 41315 41315
===========================================
- Hits 144651 117821 -26830
- Misses 30980 57998 +27018
+ Partials 2705 2517 -188
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44655/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/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.82% <0.00%> (ø)` | |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.03% <40.00%> (-0.01%)` | :arrow_down: |
| [presto](https://app.codecov.io/gh/apache/superset/pull/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.72% <0.00%> (ø)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.13% <40.00%> (-29.26%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/44655/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
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/44655?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(import): downgrade expected validation-failure logs from error to warning [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44655:
URL: https://github.com/apache/superset/pull/44655#issuecomment-5834801129
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(import): downgrade expected validation-failure logs from error to warning [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho merged PR #44655:
URL: https://github.com/apache/superset/pull/44655
--
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