Repository navigation
Accept any 2xx when updating a network policy - #42
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
f99e87c to
6ca54b8
Compare
…ect (superfly#41) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
6ca54b8 to
cc2fe3f
Compare
…ect (superfly#41) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
cc2fe3f to
e73be58
Compare
…ect (superfly#41) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| {:cowlib, "~> 2.19.0"}, | ||
| {:jason, "~> 1.4"}, | ||
| {:client_signals, "~> 0.4.4"}, | ||
| {:plug, "~> 1.0", only: :test}, |
There was a problem hiding this comment.
plug is added as a test-only dependency so the new policy tests can stub HTTP with Req.Test. Req's plug: option, Req.Test.stub/2 and Req.Test.json/2 are only compiled when Plug is available. It is only: :test, so SDK users don't pull it in. Without it, the alternative is a custom Req adapter: module in the test file.
|
@gkpacker This change looks good. Could you double-check the conflict? It looks like there's a newer version of |
The API returns 200 for POST /v1/sprites/{name}/policy/network, but
update_by_name/3 only treated 204 as success, so successful updates were
reported as {:error, {:api_error, 200, body}}. Match status in 200..299
like the rest of the SDK.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
e73be58 to
7013c88
Compare
# Conflicts: # mix.lock
|
@aezell good to go now |
Problem
The API returns 200 for
POST /v1/sprites/{name}/policy/network, butSprites.Policy.update_by_name/3(and soSprites.update_network_policy/2) only treated 204 as success. A successful update was reported as{:error, {:api_error, 200, body}}.The published OpenAPI spec (
superfly/sprites-docs/api/openapi.json) lists200(with the rules as a JSON body),400,404and500for this endpoint. It does not list 204.Fix
Change the success match to
status in 200..299. This is the same 2xx handling used everywhere else in the SDK (client.ex,filesystem.ex,Policy.get_by_name/2). Error handling for 400 and other statuses is unchanged.Tests
Added
test/policy_test.exs. HTTP is stubbed withReq.Testthrough aplug:on the client'sreq. This addsplugas a test-only dependency.:okand sends a POST to/v1/sprites/my-sprite/policy/network(this test fails without the fix):ok{:error, {:invalid_policy, body}}🤖 Generated with Claude Code