Ensure queries[language] objects are initialized#518
Conversation
src/config-utils.ts
Outdated
| ); | ||
| const queries: Queries = {}; | ||
| for (const language of languages) { | ||
| if (queries[language] === undefined) { |
There was a problem hiding this comment.
Won't this always be true? The queries variable has just been defined to be {}.
|
So in this case, all the requisite codeql suites exist (i.e. Another thing to consider to make the error message better is there's a chunk of code at the end of // The list of queries should not be empty for any language. If it is then
// it is a user configuration error.
for (const language of languages) {
if (
queries[language] === undefined ||
(queries[language].builtin.length === 0 &&
queries[language].custom.length === 0)
) {
throw new Error(
`Did not detect any queries to run for ${language}. ` +
"Please make sure that the default queries are enabled, or you are specifying queries to run."
);
}
}If you move that to |
@robertbrignull Exactly. We don't have any queries yet that match the default query selectors. |
5612390 to
17cf5fc
Compare
|
@robertbrignull Thanks for the quick review. I addressed your comments. |
robertbrignull
left a comment
There was a problem hiding this comment.
LGTM
Should be fine
| ) { | ||
| throw new Error( | ||
| `Did not detect any queries to run for ${language}. ` + | ||
| "Please make sure that the default queries are enabled, or you are specifying queries to run." |
There was a problem hiding this comment.
You could change this error message to be more accurate for the case of ruby, but also I assume this situation of having empty suites will be temporary so it doesn't matter too much.
There was a problem hiding this comment.
Yes, indeed. The important thing is that the Action no long crashes with an undefined property error.
491900c to
74c4fa0
Compare
74c4fa0 to
6a14acc
Compare
This PR improves the CodeQL action in case a query suite is used that contains no queries. This is a bit of a corner case and resulted in an error like
no property 'builtin' for 'undefined'instead of the more friendly messageUnable to analyse ruby as no queries were selected for this languageMerge / deployment checklist