fix(web): show the OpenAPI schema validation error once

Merged
RO
2d ago
+58-44

Description

Part 2 of the ENG-4416 stack. The OpenAPI modal showed the server-side schema error (e.g. the metadata-IP / SSRF refusal) twice: once from Formik on the field and once as an extra Text under it. The async validation result now lives in local definitionError state and renders once with InputErrorText, and the textarea gets the error variant.

BeforeAfter (desktop)After editing another fieldMobile
beforeafterafter editmobile

flow

How Has This Been Tested?

  • Local ODS stack: pasted a schema whose server is http://169.254.169.254.nip.io; the error shows once after input, blur, editing another field, and Continue (desktop + mobile).
  • New jest test shows a schema validation error once before and after blur; create modal + detail suites: 53 passed.
  • pre-commit on touched files.

Additional Options

  • [Optional] Please cherry-pick this PR to the latest release version.

Link to Devin session: https://app.devin.ai/sessions/09df74c24e19407bbf0e7ab775b5cb0a
Open in Devin Desktop: https://app.devin.ai/desktop/session/09df74c24e19407bbf0e7ab775b5cb0a?variant=devin
Requested by: @rohoswagger


Summary by cubic

Fixes the OpenAPI schema validation error showing twice in the modal — once from Formik on the field and once as a separate message. The server-side error (such as the metadata-IP / SSRF refusal) now lives in local definitionError state, renders once with InputErrorText, and the textarea gets the error variant. Stale validation errors are cleared whenever the definition changes, so an outdated server response won't linger while the schema is edited.

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation feedback for OpenAPI definitions, including clearer formatting and invalid JSON errors.
    • Validation messages now remain visible consistently when users move between fields or update other inputs.
    • Stale validation results are ignored to prevent outdated errors from appearing.
  • Tests

    • Added coverage ensuring schema validation errors appear once, remain singular after edits and blur, and are replaced by required-field errors when the definition is cleared.