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

[PR] fix(dataset): preserve validation error messages [superset]

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

   ### SUMMARY
   
   Fixes [Shortcut SC-115499](https://app.shortcut.com/preset/story/115499).
   
   When a calculated-column expression fails server-side validation, the dataset API can return a scalar field error:
   
   ```json
   {"message":{"columns.0.expression":"Custom SQL fields cannot be parsed as a single SQL statement."}}
   ```
   
   Other dataset validation paths return array-valued field errors such as `{"message":{"columns":["One or more columns already exist"]}}`. The scalar shape occurs because Flask-Babel `LazyString` values are not treated as Python strings by Marshmallow's `ValidationError` constructor, so they are not list-wrapped before Flask serializes them.
   
   `parseErrorJson()` asserted that every field value was `string[]` and unconditionally indexed `[0]`. For a scalar JSON string, JavaScript returned its first character, causing the dataset editor to display only `C`. This was also a structural weakness at the shared client-error normalization boundary: a valid backend response variant was forced through an unchecked type assertion.
   
   This change normalizes both scalar-string and string-array field errors at that boundary, preserves the existing invalid-input fallback for unsupported/empty values, and adds a regression test using the exact calculated-column response shape.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   No new screenshot attached.
   
   - Before: **Error saving dataset** displayed `C`.
   - After: it displays `Custom SQL fields cannot be parsed as a single SQL statement.`
   
   ### TESTING INSTRUCTIONS
   
   Automated checks run:
   
   ```bash
   # Focused regression suite: 23 passed
   npx jest packages/superset-ui-core/test/query/getClientErrorObject.test.ts --runInBand
   
   # Targeted formatting and lint
   oxfmt --check packages/superset-ui-core/src/query/getClientErrorObject.ts packages/superset-ui-core/test/query/getClientErrorObject.test.ts
   oxlint --config oxlint.json packages/superset-ui-core/src/query/getClientErrorObject.ts packages/superset-ui-core/test/query/getClientErrorObject.test.ts
   
   # Relevant TypeScript project and repository staged-file checks
   tsc --build packages/superset-ui-core
   pre-commit run
   ```
   
   Manual verification:
   
   1. Open **Datasets → birth_names → Edit**.
   2. Add a calculated column named `broken_calc` with expression `state = `.
   3. Save and confirm.
   4. Verify the error dialog shows the complete validation message rather than `C`.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: [Shortcut SC-115499](https://app.shortcut.com/preset/story/115499)
   - [ ] Required feature flags:
   - [x] 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
   
   


-- 
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(dataset): preserve validation error messages [superset]

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

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43631?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 79.17%. Comparing base ([`13e97ba`](https://app.codecov.io/gh/apache/superset/commit/13e97ba9139d15340e5e44621d54075a0b76adec?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`303b120`](https://app.codecov.io/gh/apache/superset/commit/303b120bec751b25398ded1eea51c35ece5fe6f8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #43631   +/-   ##
   =======================================
     Coverage   79.17%   79.17%           
   =======================================
     Files        2879     2879           
     Lines      165819   165825    +6     
     Branches    38330    38331    +1     
   =======================================
   + Hits       131290   131296    +6     
     Misses      32056    32056           
     Partials     2473     2473           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/43631/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/43631/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `74.60% <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/43631?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(dataset): preserve validation error messages [superset]

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

   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(dataset): preserve validation error messages [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 #43631:
URL: https://github.com/apache/superset/pull/43631#discussion_r3877714812


##########
superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts:
##########
@@ -119,20 +119,33 @@ export function retrieveErrorMessage(
   return statusError || parseStringResponse(str);
 }
 
+function getFirstValidationError(message: JsonObject): string | undefined {
+  const [firstError] = Object.values(message);
+
+  if (typeof firstError === 'string') {
+    return firstError;
+  }
+
+  if (Array.isArray(firstError)) {
+    return firstError.find((item): item is string => typeof item === 'string');
+  }
+
+  return undefined;
+}

Review Comment:
   **Suggestion:** The helper only inspects the first value in `message`. If a nested Marshmallow validation error or another unsupported first field is followed by a normal string or string-array field, `parseErrorJson` discards the usable later message and returns the generic `Invalid input` instead. Iterate through the field values until a supported message is found, or otherwise preserve an appropriate structured fallback. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Structured validation responses can lose actionable messages.
   - ⚠️ Dataset and dashboard forms may display `Invalid input`.
   - ⚠️ Users cannot identify later field-specific validation failures.
   ```
   </details>
   
   [![Use CodeAnt Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=25e8ab8fadc74af5835461d74308d1be&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=25e8ab8fadc74af5835461d74308d1be&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts
   **Line:** 122:134
   **Comment:**
   	*Logic Error: The helper only inspects the first value in `message`. If a nested Marshmallow validation error or another unsupported first field is followed by a normal string or string-array field, `parseErrorJson` discards the usable later message and returns the generic `Invalid input` instead. Iterate through the field values until a supported message is found, or otherwise preserve an appropriate structured fallback.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43631&comment_hash=3aa2fdc4ead26ad836f5f727e8088293b7f06567ba599be0ff6852fa955855a9&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43631&comment_hash=3aa2fdc4ead26ad836f5f727e8088293b7f06567ba599be0ff6852fa955855a9&reaction=dislike'>👎</a>



-- 
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(dataset): preserve validation error messages [superset]

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


-- 
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(dataset): preserve validation error messages [superset]

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

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 303b120bec751b25398ded1eea51c35ece5fe6f8 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a90ff169a5d3200086d2788 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-43631--superset-docs-preview.netlify.app](https://deploy-preview-43631--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.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQzNjMxLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.cDPYdK5gKCgxUKUqbnEaUtcEERAOg4RG8rvzIboWnyw)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctRDoMgDADQu_R7TcANhN1gx-hsVRIVUsiSxXh3-Xs_74SieS8N3gAP-Cod09pdJ7TWvWJEpkZVGv5oS90pHyiqWXGXWmmRvljKlv8f7s9TNPNsfSTHz8EYEzwPYwhw3Q) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-43631--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] fix(dataset): preserve validation error messages [superset]

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

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation of `getFirstValidationError` only inspects the first value in the `message` object, which causes it to return `undefined` (and subsequently the generic 'Invalid input' fallback) if the first field contains an unsupported structure, even if subsequent fields contain valid error strings.
   
   To resolve this, `getFirstValidationError` should iterate through all values in the `message` object until it finds a supported error message (a string or an array containing a string).
   
   **superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts**
   ```
   function getFirstValidationError(message: JsonObject): string | undefined {
     for (const value of Object.values(message)) {
       if (typeof value === 'string') {
         return value;
       }
       if (Array.isArray(value)) {
         const firstString = value.find((item): item is string => typeof item === 'string');
         if (firstString) return firstString;
       }
     }
     return undefined;
   }
   ```


-- 
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(dataset): preserve validation error messages [superset]

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

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