Classify Cloudflare bot challenges as upstream_bot_challenge instead of rejected credentials - #2127
Open
mmarabel wants to merge 1 commit into
Conversation
…of rejected credentials A response carrying cf-mitigated: challenge was served by Cloudflare's edge before the request reached the API, so the credential was never checked. OpenAPI and GraphQL invocations reported it as connection_rejected with a re-authenticate prompt and the challenge page's HTML; OpenAPI health probes marked the connection expired. Detect the documented header in the SDK and fail such calls as upstream_bot_challenge with the Ray ID. OpenAPI health probes report the challenge as degraded. Fixes UsefulSoftwareCo#2126
This branch has not been deployed
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.
Summary
An upstream response with
cf-mitigated: challenge(Cloudflare's documented challenge signal) now fails asupstream_bot_challengeand carries the Ray ID. Before, it failed asconnection_rejected, with a re-authenticate prompt and the challenge page's HTML as details. The edge answered before the request reached the API, so the credential was never checked. OpenAPI health probes now report such a response asdegraded, notexpired.@executor-js/sdk: addsdetectBotChallenge. It checks headers only, and strictly, so a page that merely looks like a challenge never classifies. Also addsbotChallengeToolFailureandbotChallengeMessage, so every protocol plugin reports the same shape and text:category: "upstream_protection",upstream.{provider, mitigation, rayId}, and recovery guidance that does not suggest a reconnect.degradedwith reasonupstream_status. No newHealthCheckReasonliteral is added, so nothing changes in the persisted schema.retryable: false.Linked issue
Fixes #2126
Verification
bun run format:checkbun run lintbun run typecheck(@executor-js/sdk,@executor-js/plugin-openapi,@executor-js/plugin-graphql)bun run testfor those packages: sdk 947, plugin-openapi 341, plugin-graphql 119, all passingNew tests:
connection_rejecteddegradedThe three OpenAPI challenge tests fail without the change.
Reproduced before the change against a live Cloudflare-fronted API from Executor Cloud (details in [bug] Cloudflare bot challenges are reported as rejected credentials #2126).
e2e: not run. This changes error classification only and adds no UI. The result shows through the existing Degraded badge and its detail text.
Checklist
bun run changeset), or this change needs none.