Skip to content

feat: let clients sync only if sync is on - #367

Merged
uniqueg merged 1 commit into
devfrom
feat/sync-only-if-on
Nov 5, 2026
Merged

uniqueg merged 1 commit into
devfrom
feat/sync-only-if-on

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Closes #365
Closes #366

Summary

  • security.cors.expose_headers: [Retry-After] in the default config, so browser apps on other origins can read the wait after a 429.
  • PUT /services/{serviceId}/sync?onlyIfEnabled=true: syncs only if sync is on; otherwise 404, without a fetch, also if sync is turned off during the fetch. A deployment without sync still returns 409 sync-unavailable.
  • API, configuration docs and release notes updated.

Verification

See below; CI result follows.

Declined review findings

  • With onlyIfEnabled, if sync is turned off during a fetch that also fails, the fetch's error (502, 400, 429, 409 sync-identity-mismatch) is returned instead of 404. Sync stays off, and a retry returns 404, so the extra checks aren't worth it.
  • A repeated parameter (?onlyIfEnabled=true&onlyIfEnabled=false) resolves to its last value. This is Connexion's general behaviour, the caller may turn sync on anyway, and it needs a client or proxy appending a duplicate.

🤖 Generated with Claude Code

Summary by Sourcery

Allow clients to request sync only while it remains enabled and expose fetch retry guidance to cross-origin browser applications.

New Features:

  • Add an onlyIfEnabled option to sync services only when synchronization is already enabled, avoiding unintended reactivation.

Bug Fixes:

  • Prevent sync requests from re-enabling synchronization when it was disabled during the request.

Enhancements:

  • Expose Retry-After through the default CORS configuration for browser clients on other origins.

Documentation:

  • Document the conditional sync behavior and browser access to Retry-After responses.
  • Update release notes for conditional service syncing and CORS header exposure.

Tests:

  • Add coverage for conditional syncing, disabled-sync behavior, concurrent disabling, unavailable sync, and exposed Retry-After headers.

Add onlyIfEnabled to PUT /services/{serviceId}/sync, and expose
Retry-After to browser apps on other origins.

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

sourcery-ai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Adds an onlyIfEnabled sync mode that avoids fetching or enabling services whose sync has been turned off, including a concurrency-safe final check, and exposes Retry-After to browser clients via default CORS configuration with corresponding API, configuration, test, and release documentation.

Sequence diagram for conditional service synchronization

sequenceDiagram
    participant Client
    participant API
    participant Registry
    participant Fetcher

    Client->>API: PUT /services/{serviceId}/sync?onlyIfEnabled=true
    API->>Registry: putServiceSync(serviceId, onlyIfEnabled)
    Registry->>Registry: Check sync is enabled
    alt Sync is disabled
        Registry-->>API: NotFound
        API-->>Client: 404 Not Found
    else Sync is enabled
        Registry->>Fetcher: Fetch service info
        Fetcher-->>Registry: Service info
        Registry->>Registry: Conditional update requires sync enabled
        alt Sync was disabled during fetch
            Registry-->>API: NotFound
            API-->>Client: 404 Not Found
        else Sync remains enabled
            Registry-->>API: Updated sync state
            API-->>Client: 200 OK
        end
    end
Loading

File-Level Changes

Change Details Files
Add conditional synchronization that refuses to enable sync when it is currently disabled.
  • Expose the optional onlyIfEnabled boolean in the sync endpoint.
  • Check sync state before fetching and re-check it when claiming the update to handle concurrent disabling.
  • Return 404 without fetching when disabled, while preserving 409 sync-unavailable for deployments without sync.
cloud_registry/api/additions.openapi.yaml
cloud_registry/ga4gh/registry/sync.py
tests/test_sync.py
Make fetch retry timing readable by cross-origin browser clients through default CORS settings.
  • Expose the Retry-After header in the default security configuration.
  • Document the browser behavior and configuration caveat.
  • Test that cross-origin 429 responses include the exposed header.
cloud_registry/config.yaml
tests/test_service_import.py
docs/api.md
docs/configuration.md
Update release documentation for the new sync option and CORS behavior.
  • Record conditional sync and browser-readable retry timing in the release notes.
docs/releases/1.0.0rc2.md

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

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (31cae10) to head (cde4329).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #367   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         3233      3238    +5     
=========================================
+ Hits          3233      3238    +5     

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

@uniqueg
uniqueg marked this pull request as ready for review November 5, 2026 08:58

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

Linked issues

#365 fix: expose Retry-After to browsers · 2 of 2 met

# Requirement Status Notes
1 Expose Retry-After to browser apps on other origins for 429 responses from service import and sync. ✅ Met The default CORS config exposes Retry-After globally, and the browser-origin test checks the header on an import 429.
2 Add tests and documentation for exposing Retry-After. ✅ Met The import test verifies Access-Control-Expose-Headers, and the configuration and API docs explain browser access to the header.

#366 feat: let clients sync only if sync is on · 3 of 3 met

# Requirement Status Notes
1 Add an optional boolean onlyIfEnabled query parameter, defaulting to false. ✅ Met The OpenAPI parameter declares the boolean type and false default, and the handler accepts it.
2 With onlyIfEnabled=true, return 404 for a service without sync, make no changes, and do not fetch. ✅ Met The handler checks whether sync is enabled before fetching; tests verify the 404 response, no fetch, and unchanged service state.
3 Add tests and documentation for conditional synchronization. ✅ Met Tests cover enabled, disabled, and sync-turned-off-during-fetch cases; the API and user docs describe the option.

Sourcery assessment

Approved.


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

@uniqueg
uniqueg merged commit 1d988ad into dev Nov 5, 2026
44 checks passed
@uniqueg
uniqueg deleted the feat/sync-only-if-on branch November 5, 2026 09:18
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: let clients sync only if sync is on fix: expose Retry-After to browsers

1 participant