Skip to content

Report parser error when encountering singleton brace expansion rule patterns#714

Merged
rcebulko merged 5 commits intoampproject:masterfrom
rcebulko:brace
Feb 21, 2020
Merged

Report parser error when encountering singleton brace expansion rule patterns#714
rcebulko merged 5 commits intoampproject:masterfrom
rcebulko:brace

Conversation

@rcebulko
Copy link
Copy Markdown
Contributor

The minimatch glob parsing library Owners Bot uses for parsing patterns performs brace-expansion, but only if the braces contain comma-separated patterns. This is not obvious behavior, and has resulted in broken owners rules (see ampproject/amphtml#26899).

Ex. "{a,b}.js" becomes /(a|b)\.js/
Ex. "{a}.js" becomes /\{a\}\.js/

This PR identifies rules where there is a single pattern specified within a brace-expansion and rejects the rule, reporting an error. This will block future PRs from submitting rules broken in this way.

/cc @Enriqe

// and has resulted in broken owners rules.
// Ex. `{a,b}.js` becomes /(a|b)\.js/
// Ex. `{a}.js` becomes /\{a\}\.js/
if (/\{[^,]+\}/.test(pattern)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

New edge-case introduced in this PR: what if the file actually includes { and } in its name? 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Then it is wrong 😆

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But actually that should be disallowed and I'm comfortable with not supporting that at present lmao

@rcebulko rcebulko merged commit ef7ed8a into ampproject:master Feb 21, 2020
@rcebulko rcebulko deleted the brace branch February 21, 2020 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants