Skip to content

chore(importers): log field names instead of full config on validation failure#42399

Open
rusackas wants to merge 1 commit into
masterfrom
chore/import-validation-debug-log
Open

chore(importers): log field names instead of full config on validation failure#42399
rusackas wants to merge 1 commit into
masterfrom
chore/import-validation-debug-log

Conversation

@rusackas

Copy link
Copy Markdown
Member

SUMMARY

When schema validation fails during an import, the debug log dumps the entire parsed config dict. Those blobs can be enormous (inline example data, multi-line keys) and bury the actual validation error that's logged right above. This trims the debug line to the file name plus its top-level field names, which is what you actually need to correlate the failure.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A (log output only)

TESTING INSTRUCTIONS

pytest tests/unit_tests/commands/importers/v1/

With debug logging enabled, import a bundle with an invalid config and confirm the log shows the field-name list instead of the full config dump.

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

🤖 Generated with Claude Code

…n failure

The debug log dumped the entire parsed config dict when schema
validation failed. Those blobs can be enormous (inline example data,
multi-line keys) and bury the actual validation error logged just
above. Log the file name and its top-level field names instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rusackas
rusackas requested review from sadpandajoe and sha174n July 24, 2026 20:40
@dosubot dosubot Bot added the logging Creates a UI or API endpoint that could benefit from logging. label Jul 24, 2026
@bito-code-review

bito-code-review Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #49d1ab

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 0155015..0155015
    • superset/commands/importers/v1/utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ 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

# Log field names only; full values can be huge (e.g. inline
# example data) and drown out the validation error above.
logger.debug(
"Config fields present in %s: %s", file_name, sorted(config)
@bito-code-review

Copy link
Copy Markdown
Contributor

The code change in superset/commands/importers/v1/utils.py addresses the security concern by removing the logging of the full config object, which could contain sensitive information. Instead, it now logs only the sorted list of field names present in the configuration. This change effectively mitigates the risk of clear-text logging of sensitive data while still providing useful debugging information.

superset/commands/importers/v1/utils.py

# Log field names only; full values can be huge (e.g. inline
                # example data) and drown out the validation error above.
                logger.debug(
                    "Config fields present in %s: %s", file_name, sorted(config)
                )

Comment on lines +235 to +237
logger.debug(
"Config fields present in %s: %s", file_name, sorted(config)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: The validation error handler can raise a new TypeError while evaluating sorted(config) when the invalid parsed configuration is None or contains incomparable top-level key types. This masks the original ValidationError and prevents it from being appended to exceptions; log the keys without sorting or guard this diagnostic operation so it cannot replace the validation failure. [error handling]

Severity Level: Major ⚠️
- ❌ Import validation can abort with `TypeError`.
- ❌ Original schema errors are not appended to `exceptions`.
- ⚠️ Invalid bundles may receive misleading failure diagnostics.
Steps of Reproduction ✅
1. Run an importer path that calls `load_configs()` in
`superset/commands/importers/v1/utils.py`, which parses each bundle configuration and
validates it at lines 224-225 with `schema.load(config)`.

2. Provide a bundle configuration whose top-level YAML mapping contains mixed key types,
such as a string field name and an integer key; the schema validation at line 224 raises
the handled `ValidationError`.

3. The `except ValidationError` block at lines 226-231 begins handling the validation
failure, then evaluates `sorted(config)` at line 236.

4. Python cannot order unlike key types during sorting, so line 236 raises `TypeError`
before line 239 appends the original `ValidationError` to `exceptions`; `load_configs()`
therefore propagates the diagnostic logging error instead of returning the collected
validation failure. A `None` configuration would likewise be unsafe if it reaches this
block, although configurations failing earlier at `config["data"]` may raise before this
handler.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/commands/importers/v1/utils.py
**Line:** 235:237
**Comment:**
	*Error Handling: The validation error handler can raise a new `TypeError` while evaluating `sorted(config)` when the invalid parsed configuration is `None` or contains incomparable top-level key types. This masks the original `ValidationError` and prevents it from being appended to `exceptions`; log the keys without sorting or guard this diagnostic operation so it cannot replace the validation failure.

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.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.20%. Comparing base (5ffdac1) to head (0155015).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42399      +/-   ##
==========================================
- Coverage   65.27%   65.20%   -0.07%     
==========================================
  Files        2795     2795              
  Lines      157549   157549              
  Branches    36039    36039              
==========================================
- Hits       102836   102734     -102     
- Misses      52736    52833      +97     
- Partials     1977     1982       +5     
Flag Coverage Δ
hive 38.43% <0.00%> (ø)
mysql 57.63% <100.00%> (ø)
postgres ?
presto 40.35% <0.00%> (ø)
python 58.95% <100.00%> (-0.13%) ⬇️
sqlite 57.30% <100.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 Harness.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logging Creates a UI or API endpoint that could benefit from logging. size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants