Skip to content

feat(cloud-registry): show field errors in form - #595

Merged
anuragxxd merged 7 commits into
devfrom
feat/536-field-errors
Nov 23, 2026
Merged

anuragxxd merged 7 commits into
devfrom
feat/536-field-errors

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

The Cloud Registry service create form shows the registry's field errors at the fields they belong to, using the field-error support of @elixir-cloud/design (#535, #576). Cloud Registry 1.0.0rc2 lists every invalid field of a rejected registration in errors of its problem details (elixir-cloud-aai/cloud-registry#317, elixir-cloud-aai/cloud-registry#378). This unblocks elixir-cloud-aai/cloud-registry-ui#132.

  • ecc-client-elixir-cloud-registry-service-create reads the problem details from the provider's error (problem of CloudRegistryError, or of a custom provider's error) with parseProblemDetails(). It maps them to its fields with mapFieldErrors() and shows each message under its control (error of input, textarea and select).

  • A field is mapped only if the form can send it in its current state: the new-type fields only with "Add new service type", the timestamps only for admins, and the custom ID (parameter: serviceId) only when one is sent. Errors of a listed type's parts (e.g. #/type/version) show at the type list.

  • Errors of the custom ID and the timestamps open "Advanced Configuration", so they aren't hidden.

  • A field's error is cleared when:

    • the field changes (any type change clears the type's errors);
    • admin is turned off (custom ID and timestamps);
    • the environment is no longer offered.

    All errors are cleared on Reset, on the next submit (also when the provider can't create) and after a successful create.

  • If fields change, or the form is reset, while a create runs, the form doesn't show the errors of those fields (and none after a reset). Each create has its own token for this. The event's fieldErrors still holds all of them.

  • ecc-service-create-failed gets two new fields:

    • fieldErrors: a message per field, keyed by the field's path in the request body (e.g. organization.url, and serviceId for the custom ID).
    • generalError: the message for the app to show. That is error if there are no field errors, else the errors that match no field, or undefined.

    error is unchanged, so existing apps keep working.

  • No validation rules were added to the component: the registry has the final say.

  • Docs: a "Field errors" section and the new event fields on the component page, and a paragraph on field errors in the providers' Errors section. Changeset: @elixir-cloud/cloud-registry minor.

Based on dev, not on #581. The only overlap with #578/#581 is the providers' docs page, where this PR adds a paragraph after the Errors example and leaves the table alone. CloudRegistryError (errors.ts), which #578 changes, isn't touched.

Verification

  • Tests first: the tests in packages/ecc-client-elixir-cloud-registry/src/components/service-create/tests/service-create-field-errors.test.ts failed against dev's component, e.g. expected '' to equal 'Must be at most 3 characters long.'.
    • The five tests added for the Sourcery findings failed before the fixes, e.g. expected 'Too long.' to equal ''. All of them pass now.
    • The tests cover all fields, unmatched pointers, problem details without errors, non-JSON bodies, new and listed types, and the admin fields together with the opening of their section.
    • They also cover fields that weren't sent and each way of clearing: on edit, type change, submit, reset, success, a provider without create, admin off and a dropped environment.
    • Further cases: edits and resets while a create runs, custom providers, and the form's required-field check.
  • npx web-test-runner --config ../../web-test.runner-config.mjs --port 8102 in packages/ecc-client-elixir-cloud-registry: 314 tests passed in Chromium and 314 in Firefox. WebKit isn't installed locally, so CI covers it.
  • npm run lint (turbo; includes the builds of all packages and the docs site): passes, 21/21 tasks. The test file has only no-non-null-assertion warnings, as the other tests do.
  • The branch was updated by merging dev, with no conflicts.
  • CI on 656c565: all checks passed: Lint, Test on Node 22 and 24 incl. WebKit, CodeQL, Codecov patch and project, Read the Docs, and CI passed.

Review

The adversarial-reviewer and quality-reviewer subagents reviewed the branch in two rounds.

  • Round 1 found an accidental Prettier reformat of the component's docs page, which broke a code fence; 92a41b8 reverts it.
  • Round 1 also found docstrings that didn't mention the hidden errors (fixed), and suggested one token per create instead of two counters (done).
  • Round 2 found no medium or high findings.

All six Sourcery threads are answered: five are fixed and one is declined (see below). A review by anuragxxd is requested.

Declined review findings

  • (Sourcery, medium) Errors of optional fields left blank should go to generalError. A field is mapped only if the form can send it in its current state (the new type's parts, the admin fields, the custom ID). An optional field left blank is still a field of the form. If the registry reports it (e.g. an environment it requires), the field is where the user fixes it. The docs now say so.
  • (quality-reviewer, medium) Define the field keys once, in a constant shared by fieldLocations, ADMIN_FIELDS and the type keys. This refactor goes beyond this issue, and tests cover each field's key.
  • (quality-reviewer, low) Simplify the guards in failureDetail. They stay, because mapFieldErrors needs the locations.
  • (quality-reviewer, low) Make fieldErrors optional in the event type. The component always sets it, and apps only read the event. An optional field would make every reader handle undefined.
  • (Self-review, low) Field errors stay after a provider switch, until the next edit, submit or reset. They belong to the input, which the form also keeps after a switch.

Open questions

None.

Closes #536

🤖 Generated with Claude Code

Summary by Sourcery

Show Cloud Registry validation errors at their corresponding service creation form fields and provide structured failure details for applications.

New Features:

  • Display Cloud Registry problem-detail field errors directly on the corresponding service creation form fields, including advanced configuration and service type fields.
  • Expose mapped fieldErrors and a deduplicated generalError through the ecc-service-create-failed event while preserving the existing error field.

Bug Fixes:

  • Prevent stale field errors from being shown after edits, resets, provider limitations, administrator changes, environment changes, or successful submissions.
  • Handle field errors safely across concurrent create requests so errors are not shown for values changed while a request was running.

Enhancements:

  • Map only errors for fields included in the current request and automatically reveal advanced configuration when its fields have errors.
  • Support problem details from both built-in and custom Cloud Registry providers.

Documentation:

  • Document field-error behavior, event payload additions, and guidance for displaying general errors without duplicating messages.

Tests:

  • Add comprehensive coverage for field mapping, custom providers, unsupported fields, clearing behavior, concurrent edits, resets, and malformed or missing problem details.

When Cloud Registry rejects a registration with field errors in its
problem details (RFC 9457 `errors` with `pointer` or `parameter`), the
service create form now shows each message at its field, using
`parseProblemDetails()` and `mapFieldErrors()` of
`@elixir-cloud/design/utils` and the controls' `error` property.

- Errors of a listed type's parts show at the type list; with a new
  type, at the group, artifact and version fields.
- Errors of the admin fields open "Advanced Configuration".
- A field's error is cleared when it changes; all on reset and submit.
- Only fields that the request sent are mapped.
- `ecc-service-create-failed` gets `fieldErrors` and `generalError`
  (the rest for the app to show); `error` is unchanged.

Docs: field errors on the component page, and the provider's Errors.

Closes #536

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

API

Extend the public ecc-service-create-failed event detail with the field errors shown by the form and the remaining general error for applications to display.

  • packages/ecc-client-elixir-cloud-registry/src/events/ecc-service-create-failed.ts L12-30

Implementation

Parse provider problem details, map errors only to fields the request can send, and track which field errors remain applicable as the form changes or a create completes.

  • packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts L357-425, L660-669, L797-812 (+20 small edits)

UI

Bind the mapped errors to the corresponding controls so users see each registry message under its field.

  • packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts L866-1304 (17 small edits)

Configuration

Record the minor package release and summarize the new field-error behavior in the changeset.

  • .changeset/cloud-registry-field-errors.md L1-5

Documentation

Document how service-create field errors are mapped and shown, and describe the new event fields and application error-handling pattern.

  • apps/documentation/pages/docs/cloud-registry/components/service-create.mdx L226-235, L281-287, L295-298 (+2 small edits)
  • apps/documentation/pages/docs/cloud-registry/providers.mdx L241

Tests

Add coverage for provider error mapping, field visibility and clearing, in-flight edits and resets, and the event detail.

  • packages/ecc-client-elixir-cloud-registry/src/components/service-create/tests/service-create-field-errors.test.ts L1-603

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.43503% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.05%. Comparing base (b35b87a) to head (26100ec).

Files with missing lines Patch % Lines
...ry/src/components/service-create/service-create.ts 99.43% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #595      +/-   ##
==========================================
+ Coverage   77.46%   78.05%   +0.59%     
==========================================
  Files          76       76              
  Lines       19477    19639     +162     
  Branches     1268     1317      +49     
==========================================
+ Hits        15087    15330     +243     
+ Misses       4368     4289      -79     
+ Partials       22       20       -2     

☔ 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.

@uniqueg
uniqueg requested a review from anuragxxd November 17, 2026 18:35
@uniqueg uniqueg self-assigned this Nov 17, 2026
@uniqueg
uniqueg marked this pull request as ready for review November 17, 2026 18:35
@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 26100ec

#536 feat(cloud-registry): show the registry's field errors · 4 of 4 met

# Requirement Status Notes
1 Map the registry’s field errors to the create form’s fields, and to edit forms where they exist. ✅ Met The create form parses the provider error’s problem, maps errors to fields available in the current form state, and displays them on the controls; no edit form exists in this package.
2 Keep a general error for responses without field errors. ✅ Met The failure event sets generalError to error when there are no parsed field errors, and reports unmatched field errors as the general message when applicable.
3 Do not add validation rules in the component; the registry has the final say. ✅ Met The change adds no form validation rules; the existing required-field checks remain.
4 Update the component docs and event documentation. ✅ Met The component page documents field errors and the fieldErrors and generalError event fields; the event type is updated as well.

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've found 6 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="399-402" />
<code_context>
+      type: "/type",
+      version: "/version",
+      description: "/description",
+      contactUrl: "/contactUrl",
+      documentationUrl: "/documentationUrl",
+      environment: "/environment",
+    };
+    if (this.newType) {
+      locations["type.group"] = "/type/group";
</code_context>
<issue_to_address>
**Omitted fields show the wrong error**

When an optional field is blank and omitted from the request, but the registry returns an error for it, `fieldLocations()` still maps the omitted field, so `handleSubmit()` places its error in `fieldErrors` instead of `generalError`; the user sees an error beside a field they did not send.

Only map errors to fields that were included in the request, and leave errors for omitted fields in `generalError`.

Also at `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:408-411`.
</issue_to_address>

### Comment 2
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="687" />
<code_context>
   private async handleSubmit(): Promise<void> {
     const provider = this.currentProvider();
     if (!provider || !provider.createService) {
+      const error = "Service creation is not supported by the current provider";
       this.dispatchEvent(
         new CustomEvent("ecc-service-create-failed", {
</code_context>
<issue_to_address>
**Previous field errors remain visible**

When a create has populated `fieldErrors` and the next submit has no provider or a provider without `createService`, `handleSubmit()` dispatches the unsupported-provider failure and returns before clearing `fieldErrors`, so errors from the previous create remain visible despite the new event reporting an empty field-error map.

Clear `fieldErrors` before the unsupported-provider check in `handleSubmit()`.

Also at `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:690`, `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:699`.
</issue_to_address>

### Comment 3
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="787" />
<code_context>
+        locations,
+      });
+      // the registry's field errors show at the fields
+      this.fieldErrors = detail.fieldErrors;
       this.dispatchEvent(
         new CustomEvent("ecc-service-create-failed", {
</code_context>
<issue_to_address>
**Late errors appear on the changed form**

When the user edits or resets the form, or changes from a new type to a listed type, while a create request is pending and that request returns field errors, the catch handler assigns errors from the submitted request to the current form; this restores errors for old values or stores new-type errors for controls that are no longer rendered, leaving the user with stale or invisible errors.

Apply a failed request's field errors only if the form state and type mode still match those submitted with the request.

Also at `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:403-407`.
</issue_to_address>

### Comment 4
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="1237" />
<code_context>
                 </ecc-utils-design-label>
                 <ecc-utils-design-input
                   id="custom-service-id"
+                  .error=${this.fieldError("serviceId")}
                   .value=${this.formData.customServiceId}
                   @ecc-input-changed=${(e: CustomEvent) => {
</code_context>
<issue_to_address>
**Admin field errors disappear**

When admin-only field errors were mapped after a failed create, then the component's `admin` property changes to false, `renderAdvancedFields()` hides these controls when `admin` becomes false, but their mapped errors remain in `fieldErrors`; because `generalError` was `undefined` when the errors matched, neither the form nor an app following the documented `generalError` guidance shows them.

When `admin` becomes false, clear those errors or move them into a general error that remains available to the app.

Also at `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:1262`, `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:1280`.
</issue_to_address>

### Comment 5
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="1016" />
<code_context>
       return html`
         <ecc-utils-design-input
           id="environment"
+          .error=${this.fieldError("environment")}
           .value=${this.formData.environment}
           @ecc-input-changed=${(e: CustomEvent) =>
</code_context>
<issue_to_address>
**Cleared environment retains its error**

When an options update causes `willUpdate()` to clear the environment value after a create set an environment field error, `willUpdate()` clears `formData.environment` without clearing its registry error, so the error remains visible beside the cleared field.

Clear the environment field error whenever `willUpdate()` clears the environment value.

Also at `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:1028`.
</issue_to_address>

### Comment 6
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/tests/service-create-field-errors.test.ts" line_range="354-357" />
<code_context>
+        headers: { "Content-Type": "application/json" },
+      });
+    const created = oneEvent(el, "ecc-service-created");
+    internals(el).handleSubmit();
+    await created;
+    await el.updateComplete;
+    expect(control(el, "service-name").error).to.equal("");
+
+    answer = () => invalid([{ detail: "Too long.", pointer: "#/name" }]);
</code_context>
<issue_to_address>
**Submit clearing is not isolated**

When a previous submission set a field error and the next submission succeeds, when the new submit succeeds, the `clears the field errors on a new submit and on reset` test checks the empty error only after the success event and update. The successful-create reset clears it too, so the test passes even if starting a new submit leaves the old field error visible.

Use a second response without field errors and assert the old field error is cleared after that submission, independently of the successful-create reset.
</issue_to_address>

Sourcery assessment

Approval pending. 6 findings to address first.

Blocking findings: packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:402, packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:687, packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:787, packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:1237, packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:1016, and 1 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

uniqueg and others added 6 commits November 21, 2026 01:15
Clear the field errors when the provider cannot create, when admin is
turned off (admin-only fields) and when the environment is dropped.
Do not show errors of fields that changed while the create ran, nor
any after a reset in that time; the event still reports them all.
Isolate the test of clearing on a new submit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the reset counter and the set of changed fields with one token
per create, so that a create only applies its field errors while it is
still the running one. Undo the reformat of the component page, keep
only its new text, and align the event docs with the hidden errors.
Test that choosing another type clears its error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move "Field errors" out of Events into its own section, cut it to
what apps need, shorten the changeset, and test that the auto-opened
Advanced Configuration trigger reports aria-expanded.

@anuragxxd anuragxxd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @uniqueg — tested locally, all green in the three browsers. I moved "Field errors" out of Events, trimmed the docs and changeset, and added a test for aria-expanded on the auto-opened section. Hope that's OK.

@anuragxxd
anuragxxd merged commit e8537ac into dev Nov 23, 2026
19 checks passed
@anuragxxd
anuragxxd deleted the feat/536-field-errors branch November 23, 2026 06:35
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.

feat(cloud-registry): show the registry's field errors

2 participants