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

chore: update close-invalid-link.js #5467

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/close-invalid-link.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = async ({ github, context }) => {

if (isBugTemplate) {
try {
const link = issue.data.body.match(/(https?:\/\/github.com\/.*)/)[0];
const link = issue.data.body.split("\n")[18].match(/(https?:\/\/g?i?s?t\.?github.com\/.*)/);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems sensitive to subtle changes; e.g. a minor change in the bug template could break the 18 positioning and would be difficult to debug. Perhaps a .matchAll with URL parsing would work more consistently for the long-term: https://github.com/googleapis/google-cloud-node/pull/5460/files#r1637082948

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True - not ideal. However your solution would fail (pass?) for the same reason, i.e., it would catch github links in the template. I think, ultimately, we need to check the input value itself. Ideally github would provide a JSON-like object for their yaml templates, especially since they support required fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const isValidLink = (await fetch(link)).ok;
if (!isValidLink) {
await closeIssue(owner, repo, number);
Expand Down
Loading