Encode URL template path params in build_url (fix Sheets range and reserved chars)
Summary
build_url currently substitutes path template parameters with raw values. This causes malformed URLs when path params contain reserved characters (notably in Google Sheets range, e.g. Sheet/Name!A1:B2, hash#1!A1:B2, non-ASCII labels).
Reproduction
Using current npm release (gws 0.3.3), dry-run output for a slash in range:
gws sheets spreadsheets values get \
--params '{"spreadsheetId":"dummy","range":"slash/1!A1:B2"}' \
--dry-run
Output URL currently becomes:
"url": "https://sheets.googleapis.com/v4/spreadsheets/dummy/values/slash/1!A1:B2"
This incorrectly splits a single range value across path segments.
Expected Behavior
Path parameters should be encoded according to URI template expansion semantics:
{var}: encode as a path segment{+var}: preserve/separators, but encode each segment
For the same example above, expected URL path is:
".../values/slash%2F1%21A1%3AB2"
Why this matters
gws is agent-first and handles raw JSON params. Correct, deterministic path encoding is needed to avoid request corruption and hard-to-debug failures for localized sheet names and reserved chars.
Proposed fix
In src/executor.rs::build_url:
- Encode
{var}expansions withencode_path_segment - Encode
{+var}with per-segment encoding preserving/ - Fail fast if a
location == "path"param is provided but no placeholder exists in template
I already prepared a patch with tests and can open a PR linked to this issue.
Opened PR #84 with a fix and tests for path-template encoding in build_url. Please take a look when convenient: https://github.com/googleworkspace/cli/pull/84