Fix binary upload bodies and numeric request headers - #123
Open
mariusvniekerk wants to merge 2 commits into
Open
mariusvniekerk wants to merge 2 commits into
mariusvniekerk wants to merge 2 commits into
Conversation
Generated binary request bodies use runtime.File, but the client passed them through its JSON marshaler and sent base64 text instead of file bytes. Send the original bytes for non-JSON media types while keeping JSON file encoding unchanged. Numeric and boolean header parameters must serialize as text. Preserve large integer values when converting generated header options so resumable upload offsets can use their generated fields.
mariusvniekerk
added a commit
to kenn-io/agentsview
that referenced
this pull request
Sep 17, 2026
Pin the runtime fixes submitted in doordash-oss/oapi-codegen-dd#123 so binary bodies remain raw bytes and numeric upload headers serialize correctly. The generated body and header fields now replace the upload request editor.
cubahno
reviewed
Sep 18, 2026
Comment on lines
+314
to
+315
| mediaType, _, _ := strings.Cut(ctLower, ";") | ||
| mediaType = strings.TrimSpace(mediaType) |
Collaborator
There was a problem hiding this comment.
Should just be mediaType := baseMediaType(contentType)
Comment on lines
+333
to
+360
| if _, stringsOnly := any(*new(V)).(string); stringsOnly { | ||
| var fields map[string]any | ||
| decoder := json.NewDecoder(bytes.NewReader(res)) | ||
| decoder.UseNumber() | ||
| if err := decoder.Decode(&fields); err != nil { | ||
| return nil, err | ||
| } | ||
| if fields == nil { | ||
| return nil, nil | ||
| } | ||
| result := make(map[string]V, len(fields)) | ||
| for key, field := range fields { | ||
| var value string | ||
| switch field := field.(type) { | ||
| case string: | ||
| value = field | ||
| case json.Number: | ||
| value = field.String() | ||
| case bool: | ||
| value = strconv.FormatBool(field) | ||
| case nil: | ||
| default: | ||
| return nil, fmt.Errorf("cannot encode %s as a scalar string: %T", key, field) | ||
| } | ||
| result[key] = any(value).(V) | ||
| } | ||
| return result, nil | ||
| } |
Collaborator
There was a problem hiding this comment.
please cover this block in tests
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.
Binary uploads now send the original file bytes instead of JSON base64. The runtime recognizes generated
Filebodies for non-JSON media types and preserves content length and replayable request bodies. JSON file payloads keep their existing encoding.Generated numeric and boolean header fields now serialize as text, preserving integer precision. This lets resumable uploads supply a binary body and
Upload-Offsetthrough generated request options without rewriting the HTTP request.generated by a clanker