Skip to content

Add --additional-detail to products create and update, and show the rows in products view - #245

Merged
gianfrancopiana merged 1 commit into
mainfrom
gumclaw/gp5002-additional-detail
Nov 27, 2026
Merged

gianfrancopiana merged 1 commit into
mainfrom
gumclaw/gp5002-additional-detail

Conversation

@gumclaw

@gumclaw gumclaw commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds --additional-detail to gumroad products create and gumroad products update, and shows a product's additional details in gumroad products view.

Depends on antiwork/gumroad#9289 — the v2 API half (read + write of additional_details, stored in the product's custom_attributes). Until that is deployed the flag is still parsed and validated, the API drops the param, and view shows no rows, so both commands behave exactly as they do today. The demo below runs against a local mock of that PR's field shape, not against production.

Why

A product's additional details are the name/value rows behind the editor's "Additional details" list (the product's custom_attributes: Pages, Format, ISBN, and so on). They could be set in the web editor and through the MCP connector, but not from the CLI: products create / products update had no flag for them and products view never showed them, so a catalogue managed from the terminal had one field that was invisible and unsettable.

What

  • products create / products update: repeatable --additional-detail "Name: value". Like the other list flags here, the flag replaces the whole list (the API's param is the list), --additional-detail "" clears the rows, and a value with no name is refused before the request: Error: --additional-detail ": 40" needs a name, e.g. "Pages: 40". The editor keeps a row by its name and the API refuses the same shape, so the CLI mirrors that rather than sending a row the API would reject.
  • Rows are sent as Rails' collection encoding, additional_details[0][name] / additional_details[0][value]. The index is in the key, so the rows arrive in order however the client emits them (Go's form encoder sorts by key, which would interleave two repeated index-less keys wrongly), and the JSON-body path (create --file, update --file) folds the indexed params back into additional_details: [{name, value}].
  • products view renders the rows under the description; a product with no rows renders exactly as before.
  • New internal/cmd/products/additional_detail_flags.go and its test, plus wiring in create.go, update.go, upload_helpers.go and view.go.

Demo

demo

Demo shows: create with two rows (Pages: 40, Format: PDF); view rendering them; update --additional-detail "" clearing them; view after the clear; view of a product that never had rows (output unchanged); and create --additional-detail ": 40" refused, with the new example line visible in the usage text. It runs against a ~60-line local mock that stores the rows it is sent the way the paired API does, and the frames are the CLI's real stdout — only the pacing is synthetic.

Tests

  • internal/cmd/products/additional_detail_flags_test.go (9 tests): create and update send the rows as indexed form params; the flag on its own satisfies update's require-any-flag guard; an unset flag sends no such params; a value with no name is refused with the API never reached; a name-only row is sent; the JSON body path folds the indexed params into [{name, value}] and keeps the form keys out of the body.
  • internal/cmd/products/products_test.go: TestView_AdditionalDetails.
  • go test ./internal/cmd/products/ -cover → ok ... 1.206s coverage: 86.4% of statements (repo floor 85%); go vet ./... clean; gofmt -l internal/cmd/products empty.
  • go test ./... also fails TestStatus_* in internal/cmd/auth and TestUserJSON* in ./test on this machine; they need a real token / config. Verified identical in a clean origin/main worktree, so they are not from this change.

AI disclosure: produced by an autonomous Gumclaw agent (Hermes; model deepseek/deepseek-v4.1-flash) from the instruction "Implement read/write for a product's additional details (custom_attributes) across API v2 and the CLI". The flag shape, the form encoding and the tests came from that session.

Refs antiwork/gumroad-private#5002

Marketing: exempt (a CLI flag plus a view line for a field the editor already has — nothing to announce) @ 062cf15

Premerge review: clean @ 062cf15

@gumclaw gumclaw self-assigned this Nov 27, 2026
@gumclaw
gumclaw marked this pull request as ready for review November 27, 2026 16:00
@tastelint

tastelint Bot commented Nov 27, 2026

Copy link
Copy Markdown

Tastelint

The only screenshot is an empty terminal with a cursor, not a user interface, so there is nothing here for me to review.

@gumclaw gumclaw added the awaiting-human Waiting on a human response/decision; assignee is that human label Nov 27, 2026
@gumclaw gumclaw assigned gianfrancopiana and unassigned gumclaw Nov 27, 2026
@gianfrancopiana
gianfrancopiana merged commit 9e64464 into main Nov 27, 2026
6 checks passed
@gumclaw gumclaw removed the awaiting-human Waiting on a human response/decision; assignee is that human label Nov 27, 2026
@gianfrancopiana
gianfrancopiana deleted the gumclaw/gp5002-additional-detail branch November 27, 2026 16:11
gianfrancopiana pushed a commit to antiwork/gumroad that referenced this pull request Nov 27, 2026
## What

Adds a product's **Additional details** — the name/value rows in the
product editor, stored in `json_data["custom_attributes"]` — to the v2
seller API, read and write.

- `Api::V2::LinksController#show` / `#index` and the create/update
responses now carry `additional_details`, an array of `{name, value}`,
next to `custom_summary` and `custom_receipt_text`.
- `create` and `update` accept `additional_details` and store it as the
product's custom attributes.
- The param is read in either shape: the JSON array a JSON client sends,
or Rails' collection encoding `additional_details[0][name]` /
`[0][value]` that a form client (the CLI, `curl -F`) sends, which Rack
reads back as a hash keyed by index. The rows are taken in index order,
so they arrive in order however the client emits the keys.

## Why

A seller can manage these rows only through the product editor. The
`custom_fields` key the v2 payload already returns is the checkout
*questions* (`CustomField`), a different feature, so it is empty on a
product that has Additional details — which is what made the gap
confusing to reproduce. The MCP connector already reads and writes them
(`get_product` / `update_product`); the API and CLI are the missing
pieces.

Normalization mirrors `Mcp::Server#normalized_additional_details`, so
the connector and the API cannot disagree about the same rows:

- the param replaces the whole list;
- each row is a text `name` and a text `value`;
- a row carrying neither is dropped (`additional_details_for_api` skips
them on read too);
- a value with no name is **refused**, not dropped: `each additional
detail needs a name; a value on its own is not saved.` The editor keeps
a row by its name, so persisting it silently would lose it on the next
edit.

## The CLI half

`antiwork/gumroad-cli#245` (draft) adds `--additional-detail "Name:
value"` to `products create` / `products update` and renders the rows in
`products view`. Its demo GIF is the end-to-end check of the form shape
this PR accepts: the CLI's exact request body,
`additional_details[0][name]=Pages&additional_details[0][value]=40&additional_details[1][name]=Format&additional_details[1][value]=PDF`,
parses to `[{"name"=>"Pages", "value"=>"40"}, {"name"=>"Format",
"value"=>"PDF"}]` and passes this controller's validation and
normalization. The tracker stays open until both are merged.

## Test Results

```
CI=1 DISABLE_SPRING=1 bin/rspec spec/controllers/api/v2/links_controller_spec.rb spec/models/concerns/product/as_json_spec.rb
356 examples, 0 failures        # 11 new: create stores + echoes (array and indexed form), whole-list replace, blank row dropped, clear, refusal shapes, show payload, blank row left out
bundle exec rubocop <the three touched files>   # 2 files inspected, no offenses detected
```

No rendered surface to screenshot: the change is a JSON field on an API
response, and the same payload shape the MCP connector already returns.

Refs antiwork/gumroad-private#5002

## Stages

- [x] Scope — read/write a product's additional details on the v2 API;
the CLI half is antiwork/gumroad-cli#245
- [x] Design — mirrors `Mcp::Server#normalized_additional_details`;
payload key `additional_details`; both the array and Rails' indexed form
encoding are accepted
- [x] Build — `Product::AsJson#additional_details_for_api`,
`Api::V2::LinksController` create/update
- [x] QA — 356 examples green (11 new), rubocop clean; no rendered
surface (a JSON response field); the CLI's real request body verified
against the controller
- [x] Shipped — Opus 5.5 premerge clean at the head; the merge call is
the product owner's (marker below)
- [ ] Market — exempt: API parity with the editor and the MCP connector,
nothing to announce
- [ ] Sell — n/a

Marketing: exempt (API field parity with the editor and the MCP
connector — no user-facing surface to announce) @
f72176a

Premerge review: clean @ f72176a

This PR was implemented with AI assistance using deepseek-v4.1-flash.

Prompts used:

- "Implement read/write for a product's additional details
(custom_attributes) across API v2 and the CLI — build the API half
first, then the CLI."
- "Mirror the MCP connector's normalization exactly, and cover the
refusal shapes with specs."

---------

Co-authored-by: gumclaw <gumclaw@users.noreply.github.com>
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