Skip to content

Fix binary upload bodies and numeric request headers - #123

Open
mariusvniekerk wants to merge 2 commits into
doordash-oss:mainfrom
mariusvniekerk:fix/binary-upload-requests
Open

mariusvniekerk wants to merge 2 commits into
doordash-oss:mainfrom
mariusvniekerk:fix/binary-upload-requests

Conversation

@mariusvniekerk

Copy link
Copy Markdown

Binary uploads now send the original file bytes instead of JSON base64. The runtime recognizes generated File bodies 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-Offset through generated request options without rewriting the HTTP request.

generated by a clanker

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.
Comment thread pkg/runtime/client.go
Comment on lines +314 to +315
mediaType, _, _ := strings.Cut(ctLower, ";")
mediaType = strings.TrimSpace(mediaType)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just be mediaType := baseMediaType(contentType)

Comment thread pkg/runtime/json.go
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
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please cover this block in tests

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants