Skip to content

fix(api): use local service info schemas - #93

Merged
uniqueg merged 2 commits into
devfrom
fix/offline-specs
Oct 20, 2026
Merged

uniqueg merged 2 commits into
devfrom
fix/offline-specs

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

The app can now start, and the tests can run, without network access (closes #76).

  • The vendored registry spec (20201108.e0358db.openapi.yaml) referenced the Service and ServiceType schemas on raw.githubusercontent.com (ga4gh-service-info v1.0.0), so connexion fetched them at every startup. The vendored service-info spec contains the same schemas: parsed, the whole document equals upstream v1.0.0. FOCA merges that spec with the registry spec, so the remote entries are removed, with a comment in the file.
  • App tests are offline. app_env blocks socket.socket.connect, and the mock identity provider raises for unknown URLs instead of passing them through.
  • test_specs_local_refs fails with a clear message if a spec file gets a non-local $ref again.

Verification

  • pytest: 71 passed on Python 3.10 and 3.12 (FOCA 0.14.0). flake8, black --check . and mypy cloud_registry pass.
  • With the old spec restored, the app tests and test_specs_local_refs fail.
  • Adversarial review:
    • The served spec differs from before only by the two removed $ref keys, which used to sit next to the merged local properties.
    • Response validation behaves the same. A service with an invalid type is rejected in both versions.
    • The whole suite passes with connect, connect_ex and getaddrinfo blocked for the entire process.
    • No other spec, script or the Dockerfile fetches remote schemas.
  • Quality review: its findings are applied. That added the spec test and an error message that names the blocked address.

Notes

  • The registry spec file is no longer self-contained: #/components/schemas/Service and ServiceType resolve only when it is merged with the service-info spec, as config.yaml does. A config overlay that replaces api.specs must keep both files.
  • The socket block covers connect only. DNS lookups are not blocked, but no lookups happen in the tests.

🤖 Generated with Claude Code

Summary by Sourcery

Make application startup and tests independent of network access by using the locally merged service-info schemas.

Bug Fixes:

  • Remove remote OpenAPI schema references so the application can start without network access.

Enhancements:

  • Ensure application tests explicitly reject unexpected network requests and verify that API specifications contain only local references.

Tests:

  • Add coverage confirming all API specification references are local and preserving offline test execution.

uniqueg and others added 2 commits October 20, 2026 06:01
The registry spec referenced the `Service` and `ServiceType` schemas
on raw.githubusercontent.com, so the app fetched them at startup and
could not start without network access. The schemas are identical to
those in the vendored service info spec, which is merged with the
registry spec, so the remote references are removed.

App tests now run without network access: sockets are blocked, and
the mock identity provider no longer passes other requests through.

Closes #76

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fail with a clear message if a vendored specification references a
remote schema again, and name the address when tests try to open a
network connection.

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

sourcery-ai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR makes application startup self-contained by removing remote OpenAPI schema references and relying on the vendored service-info specification during merge. Tests now explicitly prohibit network access, reject unexpected identity-provider requests, and validate that all API specification references remain local.

Flow diagram for offline specification and app tests

flowchart TD
    Tests[pytest] --> SpecTest[test_specs_local_refs]
    SpecTest --> LocalRefs{All $refs local?}
    LocalRefs -->|no| Fail[Fail with blocked address]
    LocalRefs -->|yes| AppTests[Application tests]
    AppTests --> app_env[app_env]
    app_env --> Socket[Block socket.socket.connect]
    AppTests --> Identity[Mock identity provider]
    Identity --> UnknownURL{Unknown URL?}
    UnknownURL -->|yes| Reject[Raise error]
    UnknownURL -->|no| Pass[Tests remain offline]
Loading

File-Level Changes

Change Details Files
Replace remote OpenAPI schema references with the vendored service-info definitions used by the merged application specification.
  • Remove the remote Service and ServiceType $ref entries from the registry spec.
  • Document that these schemas are supplied by the merged local service-info spec.
cloud_registry/api/20201108.e0358db.openapi.yaml
Enforce network-free app startup and test execution.
  • Block socket connections while constructing the configured app.
  • Make unexpected mock identity-provider requests fail explicitly instead of reaching the network.
  • Update test fixture documentation and setup for offline behavior.
tests/conftest.py
Add regression coverage ensuring API specifications contain only local references.
  • Recursively inspect YAML specifications for $ref values.
  • Fail tests when any specification contains a non-local reference.
tests/test_app.py

Assessment against linked issues

Issue Objective Addressed Explanation
#76 Remove the registry spec’s remote references to the GA4GH Service and ServiceType schemas while preserving the schemas resolved by the merged API specification. ✅
#76 Prevent regressions by checking that API specs contain no remote references and by exercising app creation with network access blocked. ✅

Possibly linked issues


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

@uniqueg
uniqueg marked this pull request as ready for review October 20, 2026 04:07
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d373f94) to head (4289fef).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev       #93   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          223       223           
=========================================
  Hits           223       223           

☔ 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 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 reviewed your changes and they look great!

Sourcery assessment

Approved.


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

@uniqueg
uniqueg merged commit 3b016bb into dev Oct 20, 2026
10 checks passed
@uniqueg
uniqueg deleted the fix/offline-specs branch October 20, 2026 04:10
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.

Specs: resolve GA4GH schemas locally (offline start)

1 participant