Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make UpsertBucket less brittle #13265

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Make UpsertBucket less brittle #13265

merged 1 commit into from
Jan 21, 2025

Conversation

JenGoldstrich
Copy link
Contributor

@JenGoldstrich JenGoldstrich commented Jan 21, 2025

Upcoming HCP SDK Go changes modified how we return the error code breaking this brittle check, I try to make it less brittle

The error goes from

{Code:5,"details":[],"message":"Error: The
bucket with identifier pkr-acctest-ancestry-parent does not exist."}

to

{"code":5,"details":[],"message":"Error: The
bucket with identifier pkr-acctest-ancestry-parent does not exist."}

Causing everything to break lol, this PR should work with both!

@JenGoldstrich JenGoldstrich requested a review from a team as a code owner January 21, 2025 18:19
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

That's a weird change, the original error message was invalid JSON?
If this is now valid, we can probably even try to deserialise it instead of doing some string manipulation there, don't we?
I'm also surprised a SDK change is the cause for this behaviour too I would've thought the SDK passed through the response from the API instead of trying to re-format it.

Besides this I would think the code would work, though I would maybe go with a regex for this one, that would be likely simpler, and more optimal (even if performance is hardly a concern here)

@JenGoldstrich JenGoldstrich merged commit cf6a82f into main Jan 21, 2025
11 checks passed
@lbajolet-hashicorp lbajolet-hashicorp deleted the less-brittle-bucket-404 branch January 21, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants