Repository navigation
feat: let clients sync only if sync is on - #367
Conversation
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]>
Reviewer's GuideAdds an Sequence diagram for conditional service synchronizationsequenceDiagram
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
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
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 a429.PUT /services/{serviceId}/sync?onlyIfEnabled=true: syncs only if sync is on; otherwise404, without a fetch, also if sync is turned off during the fetch. A deployment without sync still returns409 sync-unavailable.Verification
See below; CI result follows.
Declined review findings
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 of404. Sync stays off, and a retry returns404, so the extra checks aren't worth it.?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:
onlyIfEnabledoption to sync services only when synchronization is already enabled, avoiding unintended reactivation.Bug Fixes:
Enhancements:
Retry-Afterthrough the default CORS configuration for browser clients on other origins.Documentation:
Retry-Afterresponses.Tests:
Retry-Afterheaders.