google / google/clasp

run-function --nondev passes the project script ID, but scripts.run requires the API-executable deployment ID

Open
#1,169 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.8k
Forks
510
Avg merge
5h 27m
Merged PRs (30d)
1

Description

### Summary

`clasp run-function` always passes `.clasp.json`'s project `scriptId` to
`scripts.run`. Google documentation and the live Discovery document say this
path field must contain the API-executable deployment ID.
Both modes return `NOT_FOUND`; the equivalent raw API call succeeds with the
versioned deployment ID and `devMode:false`.

### Reproduction

1. Create a container-bound Apps Script with
`function claspPing() { return "pong"; }`.
2. Link it to a standard Cloud project.
3. Enable the Apps Script API and create a Desktop OAuth client in that project.
4. Set `executionApi.access` to `MYSELF` and declare the required runtime scope.
5. Create a versioned API-executable deployment with an `EXECUTION_API` entry point.
6. Log clasp in with the owner account and the project scopes.
7. Run `clasp --user run claspPing` and repeat with `--nondev`.

### Actual behavior

Both commands print:

`Script function not found. Please make sure script is deployed as API executable.`

The underlying request is:

`POST /v1/scripts/:run` -> 404 `Requested entity was not found.`

### Control

Using the same OAuth token and request body:

- `` + `devMode:true` -> 404
- `` + `devMode:false` -> 404
- `` + `devMode:false` -> 200, `"pong"`
- `` + `devMode:true` -> 404

### Expected behavior

At minimum, `--nondev` should call `scripts.run` with an API-executable deployment
ID and return `pong`. clasp could accept `--deployment-id`, select an unambiguous
`EXECUTION_API` deployment, or fail early with a precise instruction.

The current `NOT_FOUND` message should not claim the function is missing when the
API rejected the resource identifier.

### Environment

- `@google/clasp`: 3.2.0
- Node.js: `v26.8.1` (Homebrew)
- OS: macOS `26.6.2`
- Account: consumer Google account; caller is script owner and deployer

### References

- https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run
- https://script.googleapis.com/$discovery/rest?version=v1
- https://github.com/google/clasp/blob/v3.2.0/src/core/functions.ts#L73-L92

Contributor guide

Open the contributing guide

Research direction

Start in src/core/functions.ts around lines 73-92, then trace the run-function CLI entry point and the request sent to scripts.run. Reproduce the project-ID and API-executable deployment-ID control cases from the issue. Done means --nondev uses or requests the correct deployment identifier, and identifier failures no longer report only that the function is missing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.