Skip to content

FIX: show per-field API validation errors in the finding dialog - #3786

Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
microsoft:mainfrom
pcbeingused333:fix/frontend-422-field-errors
Open

alexcastgonz (pcbeingused333) wants to merge 1 commit into
microsoft:mainfrom
pcbeingused333:fix/frontend-422-field-errors

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Description

Fixes #3711

Cause. The backend 422 handler returns an RFC 7807 body with detail: "Request validation failed" and an errors[] array (field, message, code). toApiError only read detail/type, so the finding dialog showed just the generic text and never said which field was wrong.

Fix.

  • ApiError now carries fieldErrors (parsed defensively from errors[]; malformed entries are skipped, empty when absent).
  • FindingDialog shows the attack_result_id message (e.g. "Input should be a valid UUID") on the Evidence attack ID field, marks it invalid, and keeps Save disabled until that field is edited. Messages for other fields go in the error bar as field: message.

No backend or API contract change.

Tests and Documentation

  • errors.test.ts: parsing of errors[], malformed entries, and bodies without it.
  • FindingDialog.test.tsx: a rejected 422 shows the API message on the field, sets aria-invalid, disables Save, and re-enables it after editing.
  • The 3 new tests fail on main and the full files pass (34/34) with jest. No documentation changes needed.

This change was prepared with AI assistance (Claude Code).

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Finding validation discards the server's field-specific explanation

1 participant