Unhelpful error message on malformed selectors
@eleftherias found two examples:
-
repository.name = 'test/test' -
repository.isFork == true
@eleftherias I tried to reproduce the issue but I couldn't, with a minder instance running locally from main. I tried with these selectors:
selection:
- description: repro
entity: repository
selector: repository.name = 'test/test'
And I get:
Details: selector failed to parse: Syntax error: token recognition error at: '= '
For the isFork one:
selection:
- description: repro
entity: repository
selector: repository.isFork != 'jakubtestorg/bad-go'
I get:
Details: selector is invalid: undefined field 'isFork'
Would you mind showing me how to reproduce better? Did you test with CLI or the UI?
@jhrozek I should have clarified, this is in the UI.
@davolokh @kantord any chance the UI is not displaying the error the back end sends?
hey @jhrozek I just checked in sandbox and it seems that the BE return a 500 with that specific error message that we show
response:
{
[0] status: 'error',
[0] data: undefined,
[0] error: {
[0] message: 'Internal errors. Means some invariants expected by underlying\n' +
[0] 'system has been broken.\n' +
[0] 'Please check with the server team.',
[0] stack: 'ApiError: Internal Server Error\n' +
[0] ' at catchErrorCodes (webpack-internal:///(rsc)/./src/types/minder/generated/core/request.ts:225:15)\n' +
[0] ' at eval (webpack-internal:///(rsc)/./src/types/minder/generated/core/request.ts:264:17)\n' +
[0] ' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
[0] name: 'ApiError',
[0] status: 500,
[0] statusText: 'Internal Server Error'
[0] }
[0] }
A 500 is not expected. Let's try to debug it tomorrow together, because that's not what I saw locally - but we might have broken things in the meantime.
thank you @jhrozek, sorry for the delay, I reach out on slack but I will put some context in here too
the API that is called when we click on save is /api/v1/profile with a PUT
the body example of the call:
{"profile":{"context":{"project":"be4cab47-0817-4bd8-b8fc-f63487ba4aba"},"id":"43ee4c22-c230-40c7-8930-6baac95d1d43","name":"test","labels":[],"repository":[{"type":"stacklok/actions_check_pinned_tags","params":{},"def":{},"name":"stacklok/actions_check_pinned_tags"},{"type":"stacklok/branch_protection_enabled","params":{"branch":"main"},"def":{},"name":"stacklok/branch_protection_enabled"},{"type":"stacklok/branch_protection_allow_deletions","params":{"branch":"main"},"def":{},"name":"stacklok/branch_protection_allow_deletions"}],"buildEnvironment":[],"artifact":[],"pullRequest":[],"release":[],"pipelineRun":[],"taskRun":[],"build":[],"selection":[{"entity":"repository","selector":"test/test"}],"remediate":"off","alert":"on","type":"","version":"","displayName":"Test","selectorType":"all","rulesCount":3}}
In this case the response is a 500, the env that I tested is sandbox and staging
This ended up being a bug on the BE side (thanks @samuv for the help with debugging!). Unfortunately GH doesn't seem to be able to move the issue back from the private FE repo to the public minder repo, so I'm just going to link the PR: https://github.com/stacklok/minder/pull/4334 and close.
@jhrozek has found the issue and the fix has landed staging
Tested in staging, and now the toast has the correct message
