Skip to content

fix: shared one registry client and URL check - #137

Merged
uniqueg merged 2 commits into
devfrom
fix/common-registry-client
Nov 24, 2026
Merged

uniqueg merged 2 commits into
devfrom
fix/common-registry-client

Conversation

@AnonymousXC

@AnonymousXC AnonymousXC commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

closes #121

Summary by Sourcery

Centralize registry access and enforce consistent, normalized HTTPS service URLs across service discovery and service-info flows.

Bug Fixes:

  • Use one shared registry client and consistent service URL validation across WES, TES, and service-info requests.
  • Return a consistent 502 registry error for unavailable, invalid, or malformed registry responses.
  • Allow valid HTTPS service URLs with ports while removing query strings, fragments, and trailing slashes before use.
  • Prevent duplicate concurrent registry loads and preserve registry ordering when probing WES services.
  • Sanitize malformed WES service-info responses instead of exposing invalid fields.

Enhancements:

  • Centralize registry fetching, caching, request limits, error handling, and allowed URL normalization in a reusable registry module.
  • Encode service identifiers in service-info links and expand coverage for normalized URLs, shared requests, and service-info behavior.

Tests:

  • Add end-to-end and unit coverage for service-info links with ports, normalized service URLs, registry failures, concurrent loads, ordering, and response sanitization.

@AnonymousXC
AnonymousXC requested a review from uniqueg as a code owner November 24, 2026 11:09
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1ab7f74) to head (27e215d).

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

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Introduce the shared registry service shape and URL normalization policy that the registry readers and service calls now rely on.

  • src/lib/registry.ts L1-84

API

Update the TES and WES listing endpoints to use the shared registry client, filter and normalize service URLs, and share concurrent WES cache misses.

  • src/app/api/tasks/get-tes-servers/route.ts L2-26
  • src/app/api/workflows/get-wes-servers/route.ts L3-9, L15-21, L113-176 (+6 small edits)

Implementation

Use the shared registry client and URL policy to fetch and sanitize WES service information, with bounded requests and consistent error handling.

  • src/lib/service-info.ts L5-17, L29-103, L115-142 (+1 small edits)

UI

Encode WES service IDs when building service-info links so IDs with reserved URL characters are passed safely.

  • src/app/dashboard/workflows/_components/service-info-button.tsx L24
  • src/app/dashboard/workflows/_components/wes-server-list.tsx L211

Tests

Add coverage for registry fetching and URL validation, update endpoint and service-info expectations, and verify the port-bearing service-info flow in the browser.

  • e2e/journey.spec.ts L33-38
  • src/app/api/tasks/get-tes-servers/route.test.ts L10-19, L47-85, L111-126 (+3 small edits)
  • src/app/api/workflows/get-wes-servers/route.test.ts L53-56, L105-149, L207-212 (+5 small edits)
  • src/lib/registry.test.ts L1-154
  • src/lib/service-info.test.ts L39-74, L104-152, L175-187 (+4 small edits)

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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


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

Comment thread src/lib/service-info.ts Resolved
Comment thread src/lib/registry.ts Resolved
Comment thread src/lib/registry.ts Resolved

@uniqueg uniqueg 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 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!

@uniqueg
uniqueg merged commit ca79bfa into dev Nov 24, 2026
42 checks passed
@uniqueg
uniqueg deleted the fix/common-registry-client branch November 24, 2026 17:31
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.

fix: share one registry client and URL check

2 participants