google / clasp

🔗 Command Line Apps Script Projects
https://developers.google.com/apps-script/guides/clasp
Apache License 2.0
4.59k stars 428 forks source link

"clasp log" incorrectly reports 'The projectId "x" looks incorrect' #813

Open mgrazebrook opened 3 years ago

mgrazebrook commented 3 years ago

Expected Behavior

The project ID is valid. I'm a newb so I don't know what 'clasp logs' should do.

Actual Behavior

$ clasp logs
The projectId "1Tr-yHs6iHlYxwypCeDb4Hzj9J-truncated looks incorrect.
Did you provide the correct projectID?

However this IS a valid project ID. 
> (Note: Non-breaking issues are likely not to be prioritized. Please consider a PR in addition to your issue)

Steps to Reproduce the Problem

$ clasp logs

Specifications

Further information:

I imagine it's failing here since the ID won't match the regular expression:

clasp/src/utils.ts:227 export const isValidProjectId = (value: string) => /^[a-z][-\da-z]{5,29}$/.test(value);

My project is an Apps Script Community Connector. I'm able to push and pull. Project Properties gives no "project ID" as such, the value clasp logs quotes is the "Script ID". There is also a "Project key" but it wouldn't match this regular expression either.

To get here, I started following the Clasp Codelab but pulled my community connector instead.

PopGoesTheWza commented 3 years ago

@mgrazebrook can you suggest what the RegEx should be?

mgrazebrook commented 3 years ago

I'm sure you know the format of project IDs better than I. However the first thing that strikes me is the regex requires [a-z] as the starting character but my ID starts with a digit. However (as noted in my description) either I'm looking for the wrong ID or the terminology (the message asks for a projectID, whereas there's no such thing in the properties), so the other possibility is that I don't know how to find the right ID and if so, perhaps the documentation could be clearer.

sqrrrl commented 3 years ago

Looks like you're providing a script ID, not the project ID. The command needs the project ID of the underlying GCP project in order to read the logs. While this is part of the script metadata, it's not (yet) exposed in the management API.

Will update readme to be a little clearer, but no need to update the regex right now.

noahmercado commented 2 years ago

Any update on this issue?

marcelogaio-groovinads commented 10 months ago

No updates? Still not working

xEverth commented 9 months ago

The ProjectID is the one from the associated Google Cloud Project, not the numeric one - try changing it in .clasp.json and check if it works. Hope this helps! @marcelogaio-groovinads

PhilomathJ commented 6 months ago

I am having this very same problem. I am a contractor within Google myself, using an internal ProjectID and receiving this error. I cloned the clasp code, extracted the regex as coded: ^[a-z][-\da-z]{5,29}$/.test(value) and ran my internal projectId through a regex tester. My ProjectId fails because it have both a period and a colon in it. But This is the actual convention of internal ProjectIds!!!

I really don't have the time to fork, modify the regex to suit my needs, then deploy locally. Please can this get what should be a really quick update?

Thanks in advance