Skip to content

client: add multipart form-data support for file uploads (PRINFRA-121) - #6

Merged
somanshreddy merged 1 commit into
mainfrom
03-31-client_add_multipart_form-data_file_upload_support
Mar 31, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
03-31-client_add_multipart_form-data_file_upload_support

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Teaches the HTTP executor to handle file uploads. When a Spec has BodyEncoding: "multipart", the executor reads the file from Invocation.FilePath, wraps it in a multipart/form-data body, and sends it with the correct Content-Type boundary.

This enables the asset upload command (POST /v3/assets), which is the only multipart endpoint in the HeyGen v3 API. Without this, the executor would reject multipart requests with a usage error.

Error handling: missing file path and non-existent files both return clear error messages.

Testing

3 new tests: successful multipart upload (verifies server receives correct form data, filename, and content), missing file path error, non-existent file error. All using httptest with a temp file.

Files

  • internal/client/executor.go — multipart/form-data body construction
  • internal/client/executor_test.go — upload, missing file, non-existent file tests

somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

@somanshreddy
somanshreddy changed the base branch from 03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor to graphite-base/6 March 31, 2026 17:22
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from 47a5bd6 to b1e332c Compare March 31, 2026 17:22
@somanshreddy
somanshreddy changed the base branch from graphite-base/6 to 03-31-cmd_add_generic_command_builder_for_generated_specs March 31, 2026 17:22
@somanshreddy somanshreddy changed the title client: add multipart/form-data file upload support client: add multipart file upload support (PRINFRA-121) Mar 31, 2026
@linear

linear Bot commented Mar 31, 2026

Copy link
Copy Markdown
PRINFRA-121 CLI M1: OpenAPI codegen pipeline

Build the code generation pipeline that reads openapi/external-api.json and produces CommandSpec structs.

Scope

  • Go program in codegen/ using text/template
  • Parse OpenAPI spec, filter to v3 endpoints only
  • Generate CommandSpec data structs in gen/ (zero logic)
  • overrides.yaml for:
    • Positional arg promotion (prompt, text, file)
    • Command group naming (video-translations → translate, webhooks/endpoints → webhook)
    • Help examples per command
  • make generate SPEC=... target
  • Nested path collapsing (e.g., /webhooks/endpoints/{id}/rotate-secret → webhook rotate-secret)
  • Golden file tests for codegen output stability
  • Generate all ~30 commands, wire into Cobra at startup

Mapping Rules

  • OpenAPI tag → command group
  • POST → create, GET (list) → list, GET (by id) → get, DELETE → delete, PATCH → update
  • Path params → positional args, query params → flags, body fields → flags
  • overrides.yaml exceptions for positional promotion and group naming

Acceptance Criteria

  • make generate produces compilable CommandSpec files for all v3 endpoints
  • Adding a new endpoint to spec + re-running codegen produces new command
  • Generated help text includes descriptions and examples
  • Golden file tests pass
  • Override validation: make generate fails if overrides reference non-existent endpoints

@somanshreddy
somanshreddy force-pushed the 03-31-cmd_add_generic_command_builder_for_generated_specs branch from 038909b to 1c8298f Compare March 31, 2026 21:06
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from b1e332c to 3ddc75a Compare March 31, 2026 21:06
@somanshreddy
somanshreddy force-pushed the 03-31-cmd_add_generic_command_builder_for_generated_specs branch from 1c8298f to d9d1b26 Compare March 31, 2026 21:25
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from 3ddc75a to 1c9bc16 Compare March 31, 2026 21:25
@somanshreddy
somanshreddy force-pushed the 03-31-cmd_add_generic_command_builder_for_generated_specs branch from d9d1b26 to 6cdb863 Compare March 31, 2026 21:55
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch 3 times, most recently from 7c07ef5 to aea9abd Compare March 31, 2026 22:02
@somanshreddy
somanshreddy force-pushed the 03-31-cmd_add_generic_command_builder_for_generated_specs branch from 6cdb863 to 8ff960a Compare March 31, 2026 22:02
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from aea9abd to 7eff426 Compare March 31, 2026 22:04
@somanshreddy
somanshreddy marked this pull request as ready for review March 31, 2026 22:07
@somanshreddy
somanshreddy requested a review from jrusso1020 March 31, 2026 22:07
@somanshreddy somanshreddy changed the title client: add multipart file upload support (PRINFRA-121) client: add multipart form-data support for file uploads (PRINFRA-121) Mar 31, 2026
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from 7eff426 to f9090ec Compare March 31, 2026 22:34
@somanshreddy
somanshreddy force-pushed the 03-31-cmd_add_generic_command_builder_for_generated_specs branch from 8ff960a to 836b5d0 Compare March 31, 2026 22:34

somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Mar 31, 10:38 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 31, 10:45 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 31, 10:47 PM UTC: @somanshreddy merged this pull request with Graphite.

@somanshreddy
somanshreddy changed the base branch from 03-31-cmd_add_generic_command_builder_for_generated_specs to graphite-base/6 March 31, 2026 22:42
@somanshreddy
somanshreddy changed the base branch from graphite-base/6 to main March 31, 2026 22:44
The executor now handles BodyEncoding=="multipart" by reading the file
from inv.FilePath and sending it as multipart/form-data. This enables
the asset upload command (POST /v3/assets).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@somanshreddy
somanshreddy force-pushed the 03-31-client_add_multipart_form-data_file_upload_support branch from f9090ec to 1a210a7 Compare March 31, 2026 22:45
@somanshreddy
somanshreddy merged commit 38cc346 into main Mar 31, 2026
9 checks passed
@somanshreddy
somanshreddy deleted the 03-31-client_add_multipart_form-data_file_upload_support branch March 31, 2026 22:47
@somanshreddy somanshreddy added this to the M1: Codegen Pipeline milestone Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants