fix(bin): harden README generator link handling#7305
Open
akgitrepos wants to merge 1 commit intogoogleapis:mainfrom
Open
fix(bin): harden README generator link handling#7305akgitrepos wants to merge 1 commit intogoogleapis:mainfrom
akgitrepos wants to merge 1 commit intogoogleapis:mainfrom
Conversation
Author
|
@pearigee Would appreciate a review on this too. Thank you! |
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.
Summary
bin/generate-readme.mjsso 404 responses correctly fall back toproduct_documentationgetRepos()whenparse-link-headerreturnsnullfor malformed/unexpected Link headersProblem
The generator currently uses
validateStatus: () => truefor support docs HEAD checks. In that mode, HTTP 404 does not throw, so the fallback branch insidecatchis skipped and broken support links may be retained.getRepos()also assumesparseLinkHeader(...)always returns an object. If it returnsnull,link.nextaccess can throw and stop README generation.Root Cause
nextChanges
1) 404 fallback correctness
processMetadata(), after HEAD request, explicitly checkres.status === 404and markremoteUrlExists=false2) Link-header null safety
getRepos(), guard withif (link && link.next && link.next.url)before reading next page URL3) Testability improvements (no behavior change for CLI usage)
processMetadataandgetReposso they can be unit-tested directlyisCliExecutioncheck so importing the module does not auto-runmain()4) New tests
Added
bin/generate-readme.test.mjs:processMetadatafalls back toproduct_documentationwhen support URL HEAD responds 404getReposhandlesparseLinkHeaderreturningnullwithout throwing and still returns filtered reposValidation
node --test bin/generate-readme.test.mjsnode --check bin/generate-readme.mjsnode bin/generate-readme.mjs --use-cacheRisk Assessment
Low.
bin/generate-readme.mjsdownloadRepoMetadata -> getRepos(),main -> processMetadata())