GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Validate project-id returned from metadata server by yihanzhen · Pull Request #2822 · googleapis/google-cloud-java

Conversation

@yihanzhen

@yihanzhen yihanzhen commented Jan 30, 2018

Copy link
Copy Markdown
Contributor

Validate project-id returned from metadata server to handle cases in which a descriptive failure html page is returned instead of the project-id itself from server when projects are not running in google cloud machines.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
yihanzhen added 2 commits January 30, 2018 11:55
@yihanzhen
Validate project-id returned from metadata server to handle cases in
fe11aaf
which a descriptive failure html page is returned instead of the
projectid itself from server when projects are not running in google cloud machines.
@yihanzhen
update comments
8348feb
@yihanzhen
yihanzhen requested a review from garrettjonesgoogle as a code owner January 30, 2018 22:03
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 30, 2018
@yihanzhen
yihanzhen requested a review from pongad January 30, 2018 22:03
pongad
pongad reviewed Jan 30, 2018
View reviewed changes
Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java Outdated
* Returns true if the projectId is valid.
* projectId must be between 6 and 30 characters
* projectId can have lowercase letters, digits or hyphens
* and must start with a lowercase letter

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java Outdated
* and must start with a lowercase letter
*/
private boolean isValidProjectId(String projectId) {
Pattern p = Pattern.compile("^[a-z][a-z0-9-]*$");

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java Outdated
* projectId can have lowercase letters, digits or hyphens
* and must start with a lowercase letter
*/
private boolean isValidProjectId(String projectId) {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot

googlebot commented Jan 31, 2018

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jan 31, 2018
yihanzhen added 2 commits January 31, 2018 10:44
@yihanzhen
Validate project-id returned from metadata server to handle cases in
2c86cb2
which a descriptive failure html page is returned instead of the
projectid itself from server when projects are not running in google cloud machines.
@yihanzhen
update comments
7ab63f1
@yihanzhen
yihanzhen force-pushed the check_projectid_from_metadataserver branch from a934449 to 7ab63f1 Compare January 31, 2018 18:49
@yihanzhen
fix code review problems
52d0d98
@yihanzhen

yihanzhen commented Jan 31, 2018

Copy link
Copy Markdown
Contributor Author

PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pongad
pongad reviewed Jan 31, 2018
View reviewed changes
Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java Outdated
private static final RetrySettings NO_RETRY_SETTINGS = getDefaultRetrySettingsBuilder()
.setMaxAttempts(1).build();

private static final Pattern projectIdPattern = Pattern.compile("^[a-z][a-z0-9-]*[a-z0-9]+$");

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java Outdated
assertThat(ServiceOptions.isValidProjectId(validProjectId)).isTrue();
assertThat(ServiceOptions.isValidProjectId(invalidProjectId1)).isFalse();
assertThat(ServiceOptions.isValidProjectId(invalidProjectId2)).isFalse();
assertThat(ServiceOptions.isValidProjectId(invalidProjectId3)).isFalse();

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yihanzhen added 2 commits January 31, 2018 14:42
@yihanzhen
Fix code review problems
c88ff33
@yihanzhen
fix code review problems
04ec228
@yihanzhen

yihanzhen commented Feb 1, 2018

Copy link
Copy Markdown
Contributor Author

PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yihanzhen
fix useless parentheses
bf39d93
pongad
pongad approved these changes Feb 1, 2018
View reviewed changes
@yihanzhen
yihanzhen merged commit 536af84 into googleapis:master Feb 1, 2018
@yihanzhen yihanzhen mentioned this pull request Feb 1, 2018
Datastore - Datastore object creation fails with version 1.5.1 #2440
Closed
wsh
wsh reviewed Feb 1, 2018
View reviewed changes

@wsh wsh left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is, this change introduces a bug (it will reject project IDs with colons in them). Please consider reverting the merge.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java
&& !projectId.endsWith("-");
}

private static boolean isLowerCase(char c) {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java
return c >= 'a' && c <= 'z';
}

private static boolean isDigit(char c) {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java
return false;
}
}
return projectId.length() > 0 && isLowerCase(projectId.charAt(0))

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java
* method is primarily used to protect against DNS hijacking.
*/
static boolean isValidProjectId(String projectId) {
for (char c : projectId.toCharArray()) {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yihanzhen added a commit to yihanzhen/google-cloud-java that referenced this pull request Feb 1, 2018
@yihanzhen
Revert "Validate project-id returned from metadata server (googleapis…
2f8a445
…#2822)"

This reverts commit 536af84.
yihanzhen added a commit that referenced this pull request Feb 1, 2018
@yihanzhen
Revert "Validate project-id returned from metadata server (#2822)" (#…
0ca34ad
…2833)

This reverts commit 536af84.
chingor13 pushed a commit that referenced this pull request Feb 20, 2026
@renovate-bot
deps: update dependency io.opentelemetry:opentelemetry-exporter-loggi…
4b59e8f
…ng to v1.46.0 (#2822)
chingor13 pushed a commit that referenced this pull request Mar 30, 2026
@renovate-bot
test(deps): update cross product test dependencies (#2822)
d4bce8b
rahul2393 pushed a commit to akash329d/google-cloud-java that referenced this pull request May 21, 2026
@igorbernstein2
chore: more pacemaker into tracers (googleapis#2822)
fcb9717
* chore: more pacemaker into tracers

Change-Id: I509051afa46164524fd3292564eee2d61a91c06a

* oops, upate pacemaker visibility

Change-Id: I326e1a485c559f3e9d108d373deac5ea73913f62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@garrettjonesgoogle garrettjonesgoogle Awaiting requested review from garrettjonesgoogle
2 more reviewers
@wsh wsh wsh left review comments
@pongad pongad pongad approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@yihanzhen @googlebot @wsh @pongad
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.