fix(functions): treat invoke 2xx as success regardless of body shape (VOL-766) - #154
Open
connorckong wants to merge 1 commit into
Open
fix(functions): treat invoke 2xx as success regardless of body shape (VOL-766)#154connorckong wants to merge 1 commit into
connorckong wants to merge 1 commit into
Conversation
Invoke responses can be plain text, non-object JSON, or empty; classifying success only via the generated typed JSON fields falsely errored on genuine 2xx. Classify by HTTP status and decode the body leniently instead. Co-authored-by: Cursor <cursoragent@cursor.com>
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
volcano functions invokereported a false error on genuine 2xx responses whenever the function handler returned a non-object body (plain text, HTML, empty, or non-object JSON).InvokeFunctionused the OpenAPI-generatedInvokeFunctionWithResponseclient and only treated the call as success whenJSONDefault/JSON200were populated. Those fields are only filled for JSON object bodies. For plain text / empty / non-JSON content-types, the typed fields stay nil and the caller fell through to error classification — producing messages likeHTTP 200: plain text from functionorHTTP 204: No Content. Forapplication/jsonarrays (and other non-object JSON), the failure is even earlier:ParseInvokeFunctionClientResponsefails duringjson.UnmarshalintoFunctionInvocationResponse(map[string]interface{}), soInvokeFunctionWithResponsereturns a parse error before status-based success handling runs.InvokeFunctioncalls the raw (non-WithResponse) client method, classifies success purely by HTTP status (2xx = success), and decodes the body leniently (JSON object as-is; other JSON/plain text under a"body"key; empty body as{}). Non-2xx responses still go throughapiErrornormalization. No API request/response contract or endpoint changes; onlyinternal/api/functions.goand its tests.Validation (independent review)
mainfor plain-text 200, JSON-array 200 (unmarshal/parse failure), and empty 204; confirmed the CLI path surfacesError: failed to invoke function "...": HTTP 200: ....functions invokecommand harness).go build ./...,go vet ./...,go test ./... -count=1— all passed.error/error_description/message, 400/401/403/404/429/503, plain-text and HTML error bodies, non-error JSON objects/arrays, empty bodies, malformed JSON, and 302 redirects. No case found where a real failure is reported as success.Test plan
TestInvokeFunctionSuccessWithNonObjectBody(plain text, no content-type object JSON, JSON array, empty 204)TestInvokeFunctionErrorsNormalize(429) still passesgo test ./... -count=1volcano functions invokeprints success JSONMade with Cursor