Repository navigation
Add --additional-detail to products create and update, and show the rows in products view - #245
Merged
Merged
Conversation
…ows in products view
TastelintThe only screenshot is an empty terminal with a cursor, not a user interface, so there is nothing here for me to review. |
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>
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.
Adds
--additional-detailtogumroad products createandgumroad products update, and shows a product's additional details ingumroad products view.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 updatehad no flag for them andproducts viewnever 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.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 intoadditional_details: [{name, value}].products viewrenders the rows under the description; a product with no rows renders exactly as before.internal/cmd/products/additional_detail_flags.goand its test, plus wiring increate.go,update.go,upload_helpers.goandview.go.Demo
Demo shows:
createwith two rows (Pages: 40,Format: PDF);viewrendering them;update --additional-detail ""clearing them;viewafter the clear;viewof a product that never had rows (output unchanged); andcreate --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 satisfiesupdate'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/productsempty.go test ./...also failsTestStatus_*ininternal/cmd/authandTestUserJSON*in./teston this machine; they need a real token / config. Verified identical in a cleanorigin/mainworktree, 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