Repository navigation
fix: shared one registry client and URL check - #137
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #137 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 26 27 +1
Lines 732 765 +33
Branches 208 207 -1
=========================================
+ Hits 732 765 +33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Reviewer's GuideData structuresIntroduce the shared registry service shape and URL normalization policy that the registry readers and service calls now rely on.
APIUpdate the TES and WES listing endpoints to use the shared registry client, filter and normalize service URLs, and share concurrent WES cache misses.
ImplementationUse the shared registry client and URL policy to fetch and sanitize WES service information, with bounded requests and consistent error handling.
UIEncode WES service IDs when building service-info links so IDs with reserved URL characters are passed safely.
TestsAdd coverage for registry fetching and URL validation, update endpoint and service-info expectations, and verify the port-bearing service-info flow in the browser.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/lib/service-info.ts" line_range="115" />
<code_context>
}
- let parsedUrl: URL;
+ const baseUrl = allowedServiceUrl(server.url);
- try {
</code_context>
<issue_to_address>
**TES entries appear as WES**
When the service-info page is requested with the ID of a registered TES service whose HTTPS endpoint returns a JSON object at `/service-info`, `getWesServiceInfo` checks only whether the registry URL is allowed, not whether the entry is a WES service. A request using a registered TES service ID therefore fetches its `/service-info` endpoint and can render its fields as WES information instead of reporting that the ID is not a WES service.
Require the registry entry’s artifact to be `wes` or `wes-gateway` before fetching its service information.
</issue_to_address>
### Comment 2
<location path="src/lib/registry.ts" line_range="65" />
<code_context>
+ throw new RegistryError("The registry answer isn't a list.");
+ }
+
+ cache = { services: data as RegistryService[], at: Date.now() };
+ return cache.services;
+}
</code_context>
<issue_to_address>
**Malformed entry breaks service info**
When the registry returns an array containing a null entry before the requested WES service, `getWesServiceInfo` dereferences `item.id` while searching the cached list, so a `null` entry before the requested service throws and the page returns 502 instead of showing that service’s info.
Filter or validate registry entries before caching them, or guard entries in the service-info lookup.
</issue_to_address>
### Comment 3
<location path="src/lib/registry.ts" line_range="79" />
<code_context>
+ return null;
+ }
+
+ if (url.protocol !== "https:" || url.username || url.password) {
+ return null;
+ }
</code_context>
<issue_to_address>
**Invalid WES URLs appear available**
When a registry entry has a port or a path other than the WES API base, `allowedServiceUrl` accepts the URL, so the WES probe and service-info lookup append `/service-info` to it and query the wrong endpoint; operators following the deployment guide also get incorrect setup requirements. The entry appears available despite pointing to an unrelated or broken service.
Reject WES URLs with ports or paths other than the documented `/ga4gh/wes/v1` API base.
Also at `src/lib/registry.ts:82`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and the shared check accepts any HTTPS path and port, and getWesServiceInfo now uses it without the previous WES API path restriction. A registry entry can therefore make the server request an internal HTTPS endpoint and expose its returned information; reverting prevents future requests but cannot undo information already exposed.
Blocking findings: src/lib/service-info.ts:115, src/lib/registry.ts:65, src/lib/registry.ts:79
uniqueg
left a comment
There was a problem hiding this comment.
Thanks a lot, this is a really nice cleanup: one registry reader, one URL check, a shared cache-miss promise, the registry order kept and sanitized service info, all with 100% coverage and an e2e test for the port case.
Approving and merging to keep things moving. A few small leftovers (the deployment guide still describes the old URL rule, TES ids on the WES info page, null registry entries, size limits for the probe and service-info requests, and the rest of #121: one error shape for all API routes and the dead TES login hint) are collected in #138. If you'd like to pick that one up too, you're very welcome!
closes #121
Summary by Sourcery
Centralize registry access and enforce consistent, normalized HTTPS service URLs across service discovery and service-info flows.
Bug Fixes:
Enhancements:
Tests: