Skip to content

feat(plugins): add WES to typed backend lists - #791

Merged
uniqueg merged 4 commits into
devfrom
feat/789-wes-backend-lists
Nov 18, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/789-wes-backend-lists

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Typed backend lists (foca.plugins.backends) now know WES gateways, so
proWES no longer needs to register the API type, override the Literal
type of ServiceEntry or bypass the validation of BackendList.

  • API_TYPES["wes"] = ApiType("org.ga4gh", "wes", "/ga4gh/wes/v1", "ga4gh-wes").
  • ServiceEntry.type is Literal["ga4gh-tes", "ga4gh-wes"].
  • BackendList(entries, api=...) refuses service entries whose type isn't
    the entry_type of the API (the check the old comment anticipated), so
    create_app() fails on them.
  • ServiceEntry.api_path (optional): by default the path of the entry
    type's API; absolute, unreserved characters, no empty, . or ..
    segments; stored without trailing slash (/ becomes empty). The field
    validator only checks the value and leaves it as given; the model
    validator normalizes it. That way, subclasses that redefine the field with
    validators of their own (proTES TesServiceEntry, proWES
    WesServiceEntry) keep working, api_path: / included (regression test).
  • Docs: "Backend lists" in docs/plugins.md, the package docstring, and a
    section "Backend lists know WES" in docs/migration-0.23.md (not a
    breaking change; it describes what WES gateways can drop). This repo
    writes release notes when a release is prepared, so the changelog gets no
    entry now.

Verification

  • pytest tests/plugins/test_plugin_backends.py: 84 passed. New tests cover
    WES and TES lists both ways, WES discovery through a registry, the
    api_path defaults, normalization and invalid paths, subclass defaults,
    subclass validators, entry types without an API type, and
    entry_for(...).api_path.
  • ruff check, ruff format --check and mypy pass.
  • CI: all checks green on ca17b2b (Test matrix, lowest dependencies,
    integration, lint, docs build, chart, image scans; codecov patch and
    project pass). Locally, the full suite wasn't run, because its MongoDB
    tests use the hard-coded port 12345.

Review

Full lane: adversarial-reviewer and quality-reviewer, then a second
adversarial round. Round 1 found a high issue: the base validator stripped
/ to an empty string before the validators of proTES and proWES ran, which
refuse it. Fixed in the second commit, with a regression test. Round 2 and
Sourcery noted that subclass defaults of api_path skipped the path check;
fixed in the third commit (the model validator checks the final path).

Declined review findings

  • Quality (low): describe api_path in one place only. Declined: the
    docstring and the user docs serve different readers, and the wording now
    matches.
  • Quality (low): test BackendList with ServiceEntry subclasses.
    Declined: BackendListConfig keeps model instances as they are, and the
    type check is the same isinstance path that the base-class tests cover.
  • Adversarial (low): a stray ga4gh-wes entry in a TES gateway's list is
    refused by BackendList, not by BackendListConfig. Kept as designed:
    BackendListConfig doesn't depend on the API, and create_app() still
    fails at startup.
  • Adversarial round 2 (low): api_path is typed str | None although it is
    always a str after validation. Declined: a sentinel default would
    overwrite subclasses' own defaults (model_fields_set doesn't tell them
    apart), and proTES/proWES redeclare the field as str anyway; the
    docstring says it is set when validated.

Open questions

None.

Follow-up in proWES (drop its workaround once a FOCA release has this) is
drafted, not posted.

Closes #789

🤖 Generated with Claude Code

Summary by Sourcery

Add first-class WES support and API-path validation to typed backend lists.

New Features:

  • Support WES gateways in typed backend lists and service-entry API metadata.

Bug Fixes:

  • Reject backend entries whose service type does not match the selected API.
  • Normalize and validate configured backend API paths, including subclass defaults and overrides.

Enhancements:

  • Expose optional API paths for backends, defaulting from the corresponding API type and making them available on selected entries.

Documentation:

  • Document WES backend-list support, API-path behavior, and migration guidance for removing gateway workarounds.

Tests:

  • Add coverage for WES lists and discovery, API-path defaults and validation, subclass behavior, unsupported API types, and candidate entry paths.

uniqueg and others added 2 commits November 18, 2026 21:59
Backend lists knew TES gateways only, so WES gateways (proWES)
registered the WES API type themselves, overrode the type of
ServiceEntry and bypassed the validation of BackendList.

- API_TYPES gets "wes" (ga4gh-wes entries, /ga4gh/wes/v1).
- ServiceEntry takes type ga4gh-wes and an optional api_path, by
  default the path of the entry type's API, checked and stored
  without trailing slash, as proTES and proWES do.
- BackendList refuses backend entries of another API's type.
- Docs: backend lists in plugins.md and the module docstring; a
  note for WES gateways in the 0.23.0 migration guide.

Closes #789

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The field validator of ServiceEntry.api_path removed trailing slashes,
so validators of subclasses that redefine the field (proTES, proWES)
got "" for "/" and refused it. It now only checks the path; the model
validator removes trailing slashes, also of subclass defaults, and
refuses entry types without an API type instead of a KeyError.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg self-assigned this Nov 18, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Extend the backend API type table for WES and add validated, normalized API paths to service entries, including subclass defaults.

  • foca/plugins/backends/config.py L42-71, L160-192, L208-214 (+6 small edits)

API

Make backend lists enforce that service entries match the API type selected for the list.

  • foca/plugins/backends/lists.py L71-73, L82-88

Documentation

Document WES backend-list types, configurable API paths, and the migration guidance for gateways that can remove their workarounds.

  • docs/migration-0.23.md L19-21, L221-232
  • docs/plugins.md L189-193, L223-231, L236-239 (+1 small edits)
  • foca/plugins/backends/__init__.py L5-7, L16

Tests

Add coverage for WES lists and discovery, API-type enforcement, API-path validation and normalization, subclass behavior, and candidate lookup.

  • tests/plugins/test_plugin_backends.py L9-12, L166, L175-324

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 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b8b33fb) to head (84bb36a).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #791   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           75        75           
  Lines        10048     10076   +28     
=========================================
+ Hits         10048     10076   +28     
Flag Coverage Δ
test_unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 84bb36a

#789 feat(plugins): add WES to typed backend lists · 6 of 6 met

# Requirement Status Notes
1 Add the WES API type to API_TYPES ✅ Met API_TYPES includes the requested WES entry type and API path.
2 Accept each API's service-entry type and reject the other API's type in BackendList ✅ Met The tests cover both TES and WES lists accepting their own type and rejecting the other.
3 Optionally add api_path to ServiceEntry with the API default and path validation ✅ Met api_path defaults by entry type, is validated and normalized, and handles subclass defaults and validators.
4 Document backend lists, including the WES migration ✅ Met The backend-list docs and migration guide describe WES entries, API-specific validation, and the workaround WES gateways can drop; release notes are prepared at release time per the repository process.
5 Add tests for both APIs ✅ Met Tests cover TES and WES list type validation, along with WES registry discovery and api_path behavior.
6 Enable proWES to drop its API_TYPES registration and custom BackendList workaround ✅ Met The standard API_TYPES and BackendList now support WES; the downstream proWES follow-up is outside this repository.

@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 1 issue

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

## Individual Comments

### Comment 1
<location path="foca/plugins/backends/config.py" line_range="140" />
<code_context>
+    # the API path of the entry type by default (set when validated)
+    api_path: str | None = None
+
+    @field_validator("api_path")
+    @classmethod
+    def _check_api_path(cls, value: str | None) -> str | None:
</code_context>
<issue_to_address>
**Invalid subclass path default slips through**

When an app-defined `ServiceEntry` subclass supplies an invalid `api_path` default, `_check` only removes the trailing slash; Pydantic skips `_check_api_path` for an unvalidated field default, so the invalid path reaches app request construction and targets an incorrect endpoint.

Validate subclass defaults as well, or recheck the final normalized path in `_check`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: foca/plugins/backends/config.py:140


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

Comment thread foca/plugins/backends/config.py Resolved
Field validators don't run on defaults, so an invalid api_path default
of a ServiceEntry subclass went unchecked. The model validator now
checks the final path too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit c5b19c7 into dev Nov 18, 2026
58 checks passed
@uniqueg
uniqueg deleted the feat/789-wes-backend-lists branch November 18, 2026 22:36
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(plugins): add WES to typed backend lists

1 participant