codeant-ai-for-open-source[bot] commented on code in PR #36880:
URL: https://github.com/apache/superset/pull/36880#discussion_r3474407390


##########
superset-frontend/src/views/CRUD/hooks.ts:
##########
@@ -893,9 +922,11 @@ export function useDatabaseValidation() {
         }
 
         console.error('Unexpected error during validation:', error);
-        setIsValidating(false);
-        setHasValidated(true);
-        return {};
+        if (isLatest()) {
+          setIsValidating(false);
+          setHasValidated(true);
+        }
+        return null;

Review Comment:
   **Suggestion:** Unexpected validation failures are currently marked as 
validated by setting `hasValidated` to `true` while returning `null`. In the 
modal footer, this can enable the Connect button (`!hasValidated` check passes) 
even though no usable validation result exists and no field errors were set. 
Keep `hasValidated` false (or set a blocking error state) for this path so 
failed validation cannot be treated like a completed successful validation 
cycle. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Connect button enabled after failed validation network error.
   - ⚠️ Database modal shows no field errors on failures.
   - ⚠️ Users misinterpret validation state, retry without understanding 
underlying issue.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open the database connection modal rendered by `DatabaseModal` in
   `superset-frontend/src/features/databases/DatabaseModal/index.tsx` (see
   `renderDatabaseConnectionForm` around lines 1884–1894 and 
`renderModalFooter` around lines
   1362–1390).
   
   2. Fill in a dynamic form field (e.g. host/port/database name) so that
   `DatabaseConnectionForm` triggers blur validation via 
`getValidation={getBlurValidation}`
   at `index.tsx:88–93` and its `ValidatedInput` children call 
`validationMethods={{ onBlur:
   getValidation }}` in `CommonParameters.tsx` and `TableCatalog.tsx` (e.g.
   `CommonParameters.databaseField` at `CommonParameters.tsx:68–88` and 
`TableCatalog` at
   `TableCatalog.tsx:31–41,69–76`).
   
   3. While that blur validation is running, induce an unexpected error in the 
validate API
   call (e.g. network failure or a thrown client error without a `json()` 
method) so that
   `SupersetClient.post` inside `useDatabaseValidation.getValidation` 
(`hooks.ts` around
   lines 831–836) throws and the catch block takes the fallback branch where 
`typeof
   error.json !== 'function'`; this executes `console.error('Unexpected error 
during
   validation:', error);` followed by:
   
      - `if (isLatest()) { setIsValidating(false); setHasValidated(true); } 
return null;`
   
      in `superset-frontend/src/views/CRUD/hooks.ts:924–120`, marking 
`hasValidated` as
      `true` while returning `null` and leaving `validationErrors` unchanged 
(often still
      `null`).
   
   4. With `hasValidated === true`, `isValidating === false`, and 
`validationErrors ===
   null`, the Connect button in the modal footer becomes enabled because its 
`disabled` prop
   uses `!!(!hasValidated || isValidating || (validationErrors &&
   Object.keys(validationErrors).length > 0))` at `index.tsx:1379–1386`; the 
`!hasValidated`
   check now passes even though the last validation failed unexpectedly and 
returned `null`,
   so the UI treats this as a completed validation cycle without any usable 
result or
   field-level errors.
   ```
   </details>
   
   [![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=8f3d75802da74f12aa6e016b6fec564a&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=8f3d75802da74f12aa6e016b6fec564a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/views/CRUD/hooks.ts
   **Line:** 925:929
   **Comment:**
        *Logic Error: Unexpected validation failures are currently marked as 
validated by setting `hasValidated` to `true` while returning `null`. In the 
modal footer, this can enable the Connect button (`!hasValidated` check passes) 
even though no usable validation result exists and no field errors were set. 
Keep `hasValidated` false (or set a blocking error state) for this path so 
failed validation cannot be treated like a completed successful validation 
cycle.
   
   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%2F36880&comment_hash=ecc0312cf00e6df4473e09a6cec4c3b50f4482d76f3de6557d8708588acfa9c8&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F36880&comment_hash=ecc0312cf00e6df4473e09a6cec4c3b50f4482d76f3de6557d8708588acfa9c8&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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to