Repository navigation
Conversation
Offer the environments that the registry allows: the create form reads
`registration_rules.environments` from `GET /service-info` (Cloud
Registry 0.6.0 and later). For registries and providers without these
rules, the new property `environments` (values or `{ value, label }`)
applies; its default is today's `prod`, `test`, `dev` and `staging`. An
empty list allows any value, with a text field. A chosen environment
that is no longer offered is cleared. Export the types
`RegistrationRules` and `RegistryServiceInfo`.
Closes #461.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ignore outdated answers for the registration rules and log failures, check the property (it may come from JSON), drop empty and duplicate values, use a generic placeholder for free text, and document the provider types and the attribute. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Show the free-text environment field only if the registry or the property allows any value (an empty list), not when a list has no valid entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Declare `getServiceInfo()` of `CloudRegistryProvider` and `RestCloudRegistryProvider` with `RegistryServiceInfo`, so that consumers can read the registration rules without a cast, and warn of invalid environments in the rules. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check the fields of the create form as Cloud Registry checks registrations, and show errors at the fields while users type: URLs (schemes, host, user info, characters, percent-encodings; mailto: for contact URLs), maximum lengths, RFC 3339 timestamps and custom IDs. Service URLs must use the schemes that the registry publishes (`registration_rules.url_schemes`), else those of the new property `urlSchemes` (default `https`). Invalid submissions send nothing and fire `ecc-service-create-validation-failed` with all messages. Closes #453. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Compute the errors once per render, reference error messages only when shown and announce them politely, add the errors by field to `ecc-service-create-validation-failed`, accept URL schemes in any case, write invisible characters as escapes, and clarify the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Don't block on timestamps (the registry ignores them of non-admins), expand the advanced section and show a note at the button on failed submissions, and require the type group for the create button. Check mailto: parts separately (fragments allowed) and addresses as written, accept IPv4 hosts with a trailing dot and IPv6 zone IDs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Share the blocking-field logic and the HTTP schemes, clarify the fieldErrors() contract and the docs on timestamps and urlSchemes, put examples in messages in parentheses, and keep numeric last labels of international mailto: domains from being parsed as IPv4. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR adds registry-compatible, field-level validation to the Cloud Registry service creation form, including detailed URL and timestamp checks, blocking submission behavior, accessible error presentation, and an expanded validation event. It also makes URL schemes and environments registry-configurable via service-info registration rules with property fallbacks, updates provider/event types, and documents the new behavior. Sequence diagram for registry-aware service creation validationsequenceDiagram
participant User
participant Form as ServiceCreateForm
participant Provider as CloudRegistryProvider
participant Registry as CloudRegistry
Form->>Provider: getServiceInfo()
Provider->>Registry: GET /service-info
Registry-->>Provider: RegistryServiceInfo.registration_rules
Provider-->>Form: RegistryServiceInfo
Form->>Form: fieldErrors(true)
Form->>Form: blockingFields(errors)
alt blocking errors exist
Form->>Form: advancedOpen = true when needed
Form-->>User: Render field errors and submission note
Form-->>User: aria-invalid and aria-live messages
Form-->>User: ecc-service-create-validation-failed
else only timestamp errors or no errors
Form->>Provider: Create service request
Provider->>Registry: Submit registration
Registry-->>Provider: Created or rejected
Provider-->>Form: Result
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
There was a problem hiding this comment.
Hey - I've found 5 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="281-284" />
<code_context>
+ }
+ this.registryEnvironments = valid ? (environments as string[]) : null;
+ this.registryUrlSchemes =
+ Array.isArray(urlSchemes) &&
+ urlSchemes.length > 0 &&
+ urlSchemes.every((value) => HTTP_SCHEMES.includes(value))
+ ? urlSchemes
+ : null;
+ }
</code_context>
<issue_to_address>
**Uppercase schemes are rejected**
When `registration_rules.url_schemes` contains an uppercase or mixed-case HTTP scheme, `loadRegistrationRules()` compares schemes case-sensitively with lowercase `HTTP_SCHEMES`, discards the registry's rules, and makes the form use its property or default schemes instead of the registry's allowed schemes.
Normalize registry schemes before checking them against `HTTP_SCHEMES` and storing them.
</issue_to_address>
### Comment 2
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/validation.ts" line_range="242" />
<code_context>
+ day <= days[month - 1] &&
+ hour < 24 &&
+ minute < 60 &&
+ second <= 60 &&
+ offsetHour < 24 &&
+ offsetMinute < 60
</code_context>
<issue_to_address>
**Invalid leap seconds pass validation**
When a timestamp uses seconds `60` at a time that is not an RFC 3339 leap second, `isDateTime()` accepts the timestamp, so the form shows no warning and submits a value the registry rejects.
Accept seconds `60` only when the timestamp represents an RFC 3339 leap second.
</issue_to_address>
### Comment 3
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/validation.ts" line_range="172" />
<code_context>
+ for (const address of path.split(",")) {
+ const at = address.lastIndexOf("@");
+ const domain = address.slice(at + 1);
+ if (at <= 0 || address.slice(0, at).includes("@") || domain === "") {
+ return invalid;
+ }
</code_context>
<issue_to_address>
**Malformed email locals pass validation**
When a contact URL uses an invalid local part, such as consecutive dots, `checkMailto` verifies that the local part is nonempty and has no second `@`, but does not validate its syntax. Addresses such as `mailto:[email protected]` therefore pass the form check even though they are not valid email addresses, and the registry can reject them after submission.
Validate the local part against the email syntax accepted by the registry before treating a `mailto:` URL as valid.
</issue_to_address>
### Comment 4
<location path="packages/ecc-client-elixir-cloud-registry/src/providers/cr-provider.ts" line_range="103" />
<code_context>
createOrUpdateServiceInfo?(service: ServiceRegister): Promise<void>;
+
+ // Service info, with the registration rules (Cloud Registry 0.6.0 and later)
+ getServiceInfo(): Promise<RegistryServiceInfo>;
}
```
</code_context>
<issue_to_address>
**Existing providers stop type-checking**
When a custom provider explicitly types its implementation using the former `Promise<Service>` return type, an existing custom provider that declares `getServiceInfo(): Promise<Service>` no longer satisfies `CloudRegistryProvider`, because `Promise<Service>` is not assignable to `Promise<RegistryServiceInfo>`. Consumers implementing the previously documented provider contract fail to compile.
Preserve compatibility with the `Promise<Service>` contract and expose registration rules through a compatible optional extension or separate method.
</issue_to_address>
### Comment 5
<location path="apps/documentation/pages/docs/cloud-registry/providers.mdx" line_range="37" />
<code_context>
createOrUpdateServiceInfo?(service: ServiceRegister): Promise<void>;
+
+ // Service info, with the registration rules (Cloud Registry 0.6.0 and later)
+ getServiceInfo(): Promise<RegistryServiceInfo>;
}
```
</code_context>
<issue_to_address>
**Registration rules stay hidden**
When a consumer copies the documented provider interface and reads `getServiceInfo()`, the provider interface example declares `getServiceInfo()` first as `Promise<Service>` and again as `Promise<RegistryServiceInfo>`. Consumers following the snippet get the first overload's broader return type, so `registration_rules` is not available without a cast, contrary to the new documentation.
Replace the original `Promise<Service>` declaration in the example with `Promise<RegistryServiceInfo>` instead of adding a second declaration.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 5 findings to address first, and when registry rules no longer include the selected environment, the form clears it before submission, so a created service can be stored without the environment the user had chosen. Reverting the form change does not restore an already-created record, though the affected registration can be corrected.
Blocking findings: packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:284, packages/ecc-client-elixir-cloud-registry/src/components/service-create/validation.ts:242, packages/ecc-client-elixir-cloud-registry/src/components/service-create/validation.ts:172, packages/ecc-client-elixir-cloud-registry/src/providers/cr-provider.ts:103, apps/documentation/pages/docs/cloud-registry/providers.mdx:37
Lowercase the URL schemes published by the registry before checking them, as schemes are case-insensitive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The provider interface example declared getServiceInfo() twice; keep only the declaration with the registration rules. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in service-create.ts and its docs: keep the validation, environments and URL schemes; dev's provider handling (#502) now loads the registration rules too, and resets them without a provider. The event table takes dev's failure details (#504) and the PR's validation details. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #510 +/- ##
==========================================
- Coverage 69.93% 69.87% -0.07%
==========================================
Files 23 24 +1
Lines 5216 5942 +726
Branches 132 199 +67
==========================================
+ Hits 3648 4152 +504
- Misses 1566 1784 +218
- Partials 2 6 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@uniqueg Thanks for this, it's very thorough work. I'd prefer not to keep these rules in the component, though. The registry already enforces them, so that's where they should live. A client-side copy means about 600 lines we'd have to keep in step with the registry. If either side changes a rule, the two disagree, and the form blocks valid registrations or lets invalid ones through. Could the registry instead return a stable error code and, where possible, the field name in its This PR could then become the part that shows the registry's errors at the right fields. What do you think? |
This is a great idea! I might write an issue for that and then create a new PR though, so that the provenance of that design becomes clearer. |
|
@anuragxxd Thanks again, and agreed: the APIs should report invalid fields, and the components should only show them. I've written that up as fresh issues, so we start clean and the design has a clear origin:
We'll pick this up after the initial Cloud Registry deployment (backend and frontend). Until the new system is in place, the registry frontend works around the missing field errors as well as it can. Could you review #535, and the format in elixir-cloud-aai/foca#586 as far as it concerns the components? You have the final say on how the design package should do this. If anything there doesn't fit how you'd build it, say so in the issues before anyone starts. I'm closing this PR and #453 in favour of the new issues. The branch stays for reference. |
Summary
The create form now checks its fields the way Cloud Registry 0.6.0 checks registrations (
ExternalServiceRegister, FOCA'scheck_url()), so that users see what the API would reject with400at the field, while they type, instead of a generic error after submitting.src/components/service-create/validation.ts: maximum lengths (code points, as the registry counts them), URL checks (schemes, host, user info, whitespace and control characters, characters that must be percent-encoded, malformed percent-encodings, IPv4/IPv6 hosts including zone IDs,mailto:contact URLs with email addresses), RFC 3339 date-times, unpaired surrogates, and reserved custom service IDs (.,..,types, slashes, commas, line breaks).urlSchemes/ attributeurl-schemes(comma- or space-separated). The registry'sregistration_rules.url_schemesfromGET /service-infotakes precedence; the default ishttps. Organization and documentation URLs allowhttpandhttps; contact URLs also allowmailto:.aria-live="polite"), and fields getaria-invalidwith a red border. Missing required fields are flagged only after a submission was tried, until the form is reset.ecc-service-create-validation-failedwith{ error, errors }(errorsmaps input IDs to messages; the event type is updated).urlSchemes, and the event table.The registry still has the final say. Rare cases can slip through, e.g. international domain names that browsers accept (UTS 46) but IDNA 2008 rejects; the registry then reports them through
ecc-service-create-failed.Stacked on #505 (configurable environments). Review it after #505; GitHub shows #505's commits until that one is merged.
Closes #453
Verification
npx tsc -p tsconfig.prod.json: passes.npm run build(package): passes.npm run lint(pre-commit, whole repo): passes; only the warnings that were already there.checkUrl()against the registry's Python reference (174 URLs): no false rejections. The only remaining differences are IDNA leniency (see above).check-453-validation.mjs, about 80 assertions: every rule above, submission blocking, the event, the advanced section opening, non-blocking timestamps, registry rules versus the property) andcheck-461-environments.mjs: all pass.dev(test: set up unit, integration and e2e tests #484). fix(cloud-registry): react to provider changes #502 adds a WTR setup, and once it lands these checks can become tests there.Declined review findings
<input>: the design components don't forwardaria-invalidandaria-describedby. This needs a change in@elixir-cloud/designand belongs in a follow-up. The attributes are set on the host elements,aria-describedbyonly when there is an error, and the messages are announced througharia-live.mailto:, trimming, required). A table would add indirection without making the code shorter.checkUrl()): this is harmless, because the first message of a field wins, and it keepscheckUrl()self-contained.aria-expandeddoesn't update: the cause is in@elixir-cloud/design, not in this change. It goes into the same follow-up as the aria forwarding.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Align the Cloud Registry service creation form with API registration rules and provide actionable validation feedback before submission.
New Features:
ecc-service-create-validation-failedevent.Bug Fixes:
Enhancements:
Documentation: