Skip to content

fix(script): preserve unreserved script ID characters - #925

Open
ZIFeIYUuuuuuu wants to merge 1 commit into
googleworkspace:mainfrom
ZIFeIYUuuuuuu:fix/842-script-id-path-encoding
Open

fix(script): preserve unreserved script ID characters#925
ZIFeIYUuuuuuu wants to merge 1 commit into
googleworkspace:mainfrom
ZIFeIYUuuuuuu:fix/842-script-id-path-encoding

Conversation

@ZIFeIYUuuuuuu

Copy link
Copy Markdown

Fix Apps Script run URLs by preserving unreserved script ID characters

Problem and reproduction

gws script scripts run builds a path containing {scriptId}. The generic path encoder currently percent-encodes every non-alphanumeric character, including RFC 3986 unreserved characters such as - and _.

With this valid script ID:

1-ukYIb8XjT9KQlsj6_NbryM5UJXBwAMeY5GKtSBA05csXty3iY7DhO-P

the generated URL contains %2D and %5F. Apps Script's :run endpoint rejects that spelling with 404 even though the unencoded ID is valid.

Root cause

render_path_template always called encode_path_segment, whose stricter encoding also escapes unreserved characters. The scriptId path parameter needs RFC 3986 unreserved characters preserved.

Changes

  • Add a script ID-specific path encoding helper that retains -, _, ., and ~ while continuing to percent-encode reserved and unsafe characters.
  • Use that helper only for scriptId template parameters; all other path parameters retain existing encoding behavior.
  • Add a regression test asserting the exact Apps Script v1/scripts/{scriptId}:run URL.
  • Add the required patch changeset.

Validation

  • cargo test -p google-workspace-cli executor::tests::test_build_url_preserves_unreserved_script_id_characters -- --exact --nocapture: 1 passed.
  • cargo test -p google-workspace-cli executor::tests -- --nocapture: 34 passed.
  • cargo fmt --all: passed.
  • cargo clippy -p google-workspace-cli -- -D warnings -A clippy::collapsible-match: passed; the allow covers an existing unrelated warning in helpers/script.rs.
  • git diff --check: passed.

Reserved characters remain escaped and non-scriptId paths are unchanged. Closes #842.

@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4a5d92

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla

google-cla Bot commented Sep 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ZIFeIYUuuuuuu
ZIFeIYUuuuuuu force-pushed the fix/842-script-id-path-encoding branch from 52bd0fe to f4a5d92 Compare September 9, 2026 10:22
@googleworkspace-bot

Copy link
Copy Markdown
Collaborator

/gemini review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

script scripts run percent-encodes unreserved characters in scriptId path parameter, causing 404

2 participants