growthbook / growthbook/cli

`--body -` not treated as stdin (parsed as literal JSON)

Open Beginner friendly
#25 0 comments 0 reactions 0 assignees View on GitHub
bug custom
Dominant language
Go
Stars
1
Forks
0
Avg merge
1d 5h
Merged PRs (30d)
18

Description

## Bug

`--body -` fails with `invalid character '-' in numeric literal` — the `-` is parsed as literal JSON instead of meaning "read the body from stdin". The conventional Unix idiom isn't supported. (A bare pipe to stdin with no `--body` flag does work.)

## Root cause (Speakeasy)

The generated body handling in `flagutil.BuildRequest` and `BuildRequestBody` passes the `--body` flag value straight to `json.Unmarshal` without honoring the `-`=stdin convention.

## Stopgap fix (retire when upstream is fixed)

`.speakeasy/patches/internal/flagutil/metadata.go.patch`: new `resolveDashStdin(cmd, val)` helper reads stdin when `val == "-"`, applied in both the whole-body path (`BuildRequest`) and the per-field body path (`BuildRequestBody`).

**To retire:** once the generated body handling treats a lone `-` as stdin, drop those hunks.

## Refs

- Introduced by #23
- Upstream: file to speakeasy-api/speakeasy (generated body/flag handling).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with .speakeasy/patches/internal/flagutil/metadata.go.patch and inspect the referenced flagutil.BuildRequest and BuildRequestBody paths. Reproduce the issue with --body - and stdin input, then verify that a lone dash is read from stdin in both whole-body and per-field handling without changing the existing bare-stdin behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.