This repository was archived by the owner on Nov 20, 2025. It is now read-only.
feat: Support Not Requiring projectId When Not Required#1448
Merged
danielbankhead merged 4 commits intomainfrom Aug 31, 2022
Merged
feat: Support Not Requiring projectId When Not Required#1448danielbankhead merged 4 commits intomainfrom
projectId When Not Required#1448danielbankhead merged 4 commits intomainfrom
Conversation
Contributor
Author
|
This PR should be followed-up with an issue for removing |
ruyadorno
reviewed
Aug 29, 2022
Comment on lines
+214
to
+215
| e instanceof Error && | ||
| e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND |
There was a problem hiding this comment.
checking for instanceof Error is quite redundant here, if it threw like an error and has a message property like an error, it's def going to be an error 😄
Suggested change
| e instanceof Error && | |
| e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND | |
| e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND |
Contributor
Author
There was a problem hiding this comment.
Understandable; the instanceof Error check is more-so a type assertion. By default, TS considers 'e' unknown
Comment on lines
+209
to
+222
| async #getProjectIdOptional(): Promise<string | null> { | ||
| try { | ||
| return await this.getProjectId(); | ||
| } catch (e) { | ||
| if ( | ||
| e instanceof Error && | ||
| e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND | ||
| ) { | ||
| return null; | ||
| } else { | ||
| throw e; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Leveraging the Promises API (similar to the previous PR) 😄 might simplify it a bit here again:
Suggested change
| async #getProjectIdOptional(): Promise<string | null> { | |
| try { | |
| return await this.getProjectId(); | |
| } catch (e) { | |
| if ( | |
| e instanceof Error && | |
| e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND | |
| ) { | |
| return null; | |
| } else { | |
| throw e; | |
| } | |
| } | |
| } | |
| #getProjectIdOptional(): Promise<string | null> { | |
| return this.getProjectId() | |
| .catch (e => { | |
| if (e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND) { | |
| return null; | |
| } else { | |
| throw e; | |
| } | |
| }) | |
| } |
ruyadorno
approved these changes
Aug 31, 2022
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
Aug 31, 2022
🤖 I have created a release *beep* *boop* --- ## [8.5.0](v8.4.0...v8.5.0) (2022-08-31) ### Features * Support Not Requiring `projectId` When Not Required ([#1448](#1448)) ([b37489b](b37489b)) ### Bug Fixes * add hashes to requirements.txt ([#1544](#1544)) ([#1449](#1449)) ([54afa8e](54afa8e)) * remove `projectId` check for `signBlob` calls ([6c04661](6c04661)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
GautamSharda
pushed a commit
to googleapis/google-cloud-node-core
that referenced
this pull request
Oct 9, 2025
🤖 I have created a release *beep* *boop* --- ## [8.5.0](googleapis/google-auth-library-nodejs@v8.4.0...v8.5.0) (2022-08-31) ### Features * Support Not Requiring `projectId` When Not Required ([#1448](googleapis/google-auth-library-nodejs#1448)) ([b37489b](googleapis/google-auth-library-nodejs@b37489b)) ### Bug Fixes * add hashes to requirements.txt ([#1544](googleapis/google-auth-library-nodejs#1544)) ([#1449](googleapis/google-auth-library-nodejs#1449)) ([54afa8e](googleapis/google-auth-library-nodejs@54afa8e)) * remove `projectId` check for `signBlob` calls ([6c04661](googleapis/google-auth-library-nodejs@6c04661)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
GautamSharda
pushed a commit
to googleapis/google-cloud-node-core
that referenced
this pull request
Oct 21, 2025
🤖 I have created a release *beep* *boop* --- ## [8.5.0](googleapis/google-auth-library-nodejs@v8.4.0...v8.5.0) (2022-08-31) ### Features * Support Not Requiring `projectId` When Not Required ([#1448](googleapis/google-auth-library-nodejs#1448)) ([b37489b](googleapis/google-auth-library-nodejs@b37489b)) ### Bug Fixes * add hashes to requirements.txt ([#1544](googleapis/google-auth-library-nodejs#1544)) ([#1449](googleapis/google-auth-library-nodejs#1449)) ([54afa8e](googleapis/google-auth-library-nodejs@54afa8e)) * remove `projectId` check for `signBlob` calls ([6c04661](googleapis/google-auth-library-nodejs@6c04661)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
GautamSharda
pushed a commit
to googleapis/google-cloud-node-core
that referenced
this pull request
Oct 30, 2025
🤖 I have created a release *beep* *boop* --- ## [8.5.0](googleapis/google-auth-library-nodejs@v8.4.0...v8.5.0) (2022-08-31) ### Features * Support Not Requiring `projectId` When Not Required ([#1448](googleapis/google-auth-library-nodejs#1448)) ([b37489b](googleapis/google-auth-library-nodejs@b37489b)) ### Bug Fixes * add hashes to requirements.txt ([#1544](googleapis/google-auth-library-nodejs#1544)) ([#1449](googleapis/google-auth-library-nodejs#1449)) ([54afa8e](googleapis/google-auth-library-nodejs@54afa8e)) * remove `projectId` check for `signBlob` calls ([6c04661](googleapis/google-auth-library-nodejs@6c04661)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
miguelvelezsa
pushed a commit
to googleapis/google-cloud-node-core
that referenced
this pull request
Nov 6, 2025
🤖 I have created a release *beep* *boop* --- ## [8.5.0](googleapis/google-auth-library-nodejs@v8.4.0...v8.5.0) (2022-08-31) ### Features * Support Not Requiring `projectId` When Not Required ([#1448](googleapis/google-auth-library-nodejs#1448)) ([b37489b](googleapis/google-auth-library-nodejs@b37489b)) ### Bug Fixes * add hashes to requirements.txt ([#1544](googleapis/google-auth-library-nodejs#1544)) ([#1449](googleapis/google-auth-library-nodejs#1449)) ([54afa8e](googleapis/google-auth-library-nodejs@54afa8e)) * remove `projectId` check for `signBlob` calls ([6c04661](googleapis/google-auth-library-nodejs@6c04661)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
miguelvelezsa
pushed a commit
to googleapis/google-cloud-node-core
that referenced
this pull request
Nov 6, 2025
🤖 I have created a release *beep* *boop* --- ## [8.5.0](googleapis/google-auth-library-nodejs@v8.4.0...v8.5.0) (2022-08-31) ### Features * Support Not Requiring `projectId` When Not Required ([#1448](googleapis/google-auth-library-nodejs#1448)) ([b37489b](googleapis/google-auth-library-nodejs@b37489b)) ### Bug Fixes * add hashes to requirements.txt ([#1544](googleapis/google-auth-library-nodejs#1544)) ([#1449](googleapis/google-auth-library-nodejs#1449)) ([54afa8e](googleapis/google-auth-library-nodejs@54afa8e)) * remove `projectId` check for `signBlob` calls ([6c04661](googleapis/google-auth-library-nodejs@6c04661)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are numerous cases where
projectIdisn't required to useGoogleAuth.In fact, I'm failing to find a place where
projectIdis a hard requirement within the library (includingsign, which erroneously requires it and will be removed in this pr: #1447).Fixes #755 🦕