@@ -33,6 +33,9 @@ def respond(self):
3333 code = 429
3434 payload = {"error" : {"code" : "RATE_LIMITED" , "message" : KEY ,
3535 "retryable" : True , "retry_after_seconds" : 4 }, "request_id" : "fixture-request" }
36+ elif self .path in ("/v1/budget" , "/v1/conflict" , "/v1/jobs/not-owned" ):
37+ code , label = {"/v1/budget" : (402 , "BUDGET_EXCEEDED" ), "/v1/conflict" : (409 , "IDEMPOTENCY_CONFLICT" ), "/v1/jobs/not-owned" : (404 , "NOT_FOUND" )}[self .path ]
38+ payload = {"error" : {"code" : label , "message" : "Fixture rejection" , "retryable" : False }}
3639 elif self .path == "/v1/gateway" :
3740 code , payload = 502 , b"<html>upstream failed</html>"
3841 elif self .path == "/v1/malformed" :
@@ -94,6 +97,16 @@ def test_no_automatic_retry_and_safe_errors(self):
9497 self .client .request ("GET" , "/v1/malformed" )
9598 self .assertEqual (ctx .exception .code , "INVALID_RESPONSE" )
9699
100+ def test_budget_conflict_and_inaccessible_job_errors_are_not_retried (self ):
101+ for path , status , code in [("/v1/budget" , 402 , "BUDGET_EXCEEDED" ),
102+ ("/v1/conflict" , 409 , "IDEMPOTENCY_CONFLICT" ),
103+ ("/v1/jobs/not-owned" , 404 , "NOT_FOUND" )]:
104+ with self .assertRaises (ApiError ) as ctx :
105+ self .client .request ("GET" , path )
106+ self .assertEqual ((ctx .exception .status , ctx .exception .code ), (status , code ))
107+ self .assertFalse (ctx .exception .retryable )
108+ self .assertEqual (len (Handler .calls ), 3 )
109+
97110 def test_redirect_never_followed (self ):
98111 with self .assertRaises (ApiError ) as ctx :
99112 self .client .request ("GET" , "/v1/redirect" )
@@ -116,9 +129,11 @@ def test_rejects_credential_and_submission_hazards_before_network(self):
116129 for key in (None , "short" , "has\n newline" ):
117130 with self .assertRaises (ValueError ):
118131 self .client .create_job ({}, idempotency_key = key )
119- for path in ("https://example.com" , "/v1/../secret" , "/v1/jobs?x=1" ):
132+ for path in ("https://example.com" , "/v1/../secret" , "/v1/%2e%2e/secret" , "/v1/ jobs?x=1" ):
120133 with self .assertRaises (ValueError ):
121134 self .client .request ("GET" , path )
135+ with self .assertRaises (ValueError ):
136+ self .client .request ("post" , "/v1/jobs" , body = {})
122137 self .assertEqual (Handler .calls , [])
123138
124139 def test_polling_terminal_failure_and_timeout_preserve_state (self ):
0 commit comments