fix(serverless-auth): fail closed on unexpected upstream status#2238
Open
rafel-roboflow wants to merge 1 commit intomainfrom
Open
fix(serverless-auth): fail closed on unexpected upstream status#2238rafel-roboflow wants to merge 1 commit intomainfrom
rafel-roboflow wants to merge 1 commit intomainfrom
Conversation
Unknown status codes from get_serverless_usage_check_async now return 503 without caching, instead of silently authorizing the request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a silent-authorization bug in
check_authorization_serverless. Whenget_serverless_usage_check_asyncreturned any status other than 200/401/402 (e.g. 429, 500, 503), the if/elif chain fell through and the request was served withworkspace_id = None, bypassing billing verification.Now any unrecognized upstream status:
"Authorization service temporarily unavailable. Please retry.")Related Issue(s): N/A
Type of Change
Testing
Test details:
Added
test_serverless_auth_middleware_fails_closed_on_unexpected_upstream_statusintests/inference/unit_tests/core/interfaces/http/test_http_api.py. It mocks the usage check to return status 503 and asserts the middleware:WORKSPACE_ID_HEADERmodel_manager.add_model/infer_from_request_syncChecklist
Additional Context
Fails closed rather than open on transient upstream errors. The previous behavior also caused OTel spans to report
auth.result="authorized"for these requests, masking upstream failures in traces.Note
High Risk
Changes serverless authorization/billing gate behavior: unexpected upstream statuses now block requests with a 503, which could impact availability but closes a potential authorization bypass.
Overview
Prevents serverless requests from being treated as authorized when
get_serverless_usage_check_asyncreturns an unrecognized status code (e.g. 429/5xx).check_authorization_serverlessnow logs a warning and returns503with a retryable message, and deliberately does not cache these failures so each request re-checks upstream; adds a unit test asserting this fail-closed, no-caching behavior.Reviewed by Cursor Bugbot for commit fe521ce. Bugbot is set up for automated code reviews on this repo. Configure here.