ci-automation: Report missing Azure product and plan lookups - #4217
Open
Shivanshu-GITH wants to merge 1 commit into
Open
ci-automation: Report missing Azure product and plan lookups#4217Shivanshu-GITH wants to merge 1 commit into
Shivanshu-GITH wants to merge 1 commit into
Conversation
get_product_durable_id and get_plan_durable_id index the product-ingestion
response with [0] straight after .get("value", []). The default anticipates a
missing key, but the index runs either way, so an offer or plan that does not
exist fails with a bare IndexError instead of naming what was not found.
Check the list before indexing and raise with the externalId that was looked
up. Also call raise_for_status, so an HTTP error is reported as a request
failure rather than reaching the same line as an empty body.
get_image_versions already uses the safe .get form, so this brings the two
lookups in line with the rest of the file.
Signed-off-by: Shivanshu-GITH <shivanshu.um@gmail.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix
get_product_durable_idandget_plan_durable_idinci-automation/release/azure_marketplace_publish.pyindex the product-ingestion responsewith
[0]straight after.get("value", []):The
.get("value", [])default anticipates a missing key, but the index runs either way, soa response with no results fails with a bare
IndexError: list index out of range. During arelease publish that means an operator gets a traceback instead of a message saying which
offer or plan was not found.
This checks the list before indexing and raises with the
externalIdthat was looked up. Italso calls
raise_for_status(), so an HTTP error is reported as a request failure ratherthan reaching the same line as an empty body.
get_image_versions()a few lines below already uses the safe.getform, so this bringsthe two lookups in line with the rest of the file.
Reported in flatcar/Flatcar#2309.
How to use
No change in behaviour on the success path — the functions return the same durable id as
before. The difference is only visible when a lookup comes back empty or the request fails,
where the script now stops with a named error instead of an
IndexError.Reviewers may want to confirm the choice of raising over returning
None: the caller doesproduct_durable_id.split("/")[1]immediately afterwards, so returningNonewould move thefailure one line down rather than remove it. Happy to switch to a
logging.errorandcontinuein the caller loop instead, matching thegenerate_az_sas_urlcase, if that fitsbetter.
Testing done
I do not have Azure marketplace credentials, so the script has not been run against the live
Microsoft product-ingestion API. Instead I loaded the two patched functions directly and
stubbed only
requestsand the azure SDK, so the logic under test is the shipped logic:The first three cases are what raised
IndexErrorbefore:Changelog entries added in the respective
changelog/directory (user-facing change, bug fix, security fix, update)Not added —
changelog/README.mdsays entries should only contain information relevant toend users, and this is internal release automation. Happy to add one if you would rather
have it recorded.
Inspected CI output for image differences:
/bootand/usrsize, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.Not applicable — no image content is touched.
An LLM was used in producing this change.