Skip to content

[BUGFIX]: fix prometheus queryParam interpolation does not work for customAllValue#181

Open
zhuje wants to merge 2 commits into
perses:mainfrom
zhuje:fix/queryparam-customallvalue
Open

[BUGFIX]: fix prometheus queryParam interpolation does not work for customAllValue#181
zhuje wants to merge 2 commits into
perses:mainfrom
zhuje:fix/queryparam-customallvalue

Conversation

@zhuje

@zhuje zhuje commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

PR to address perses/perses#4155

Before 
?namespace=namespace%3D(project-alpha%7Cproject-beta%7Cproject-gamma)
After 
?namespace=project-alpha&namespace=project-beta&namespace=project-gamma

Screenshots

Screenshot 2026-06-24 at 10 28 59 AM Figure. Shows the dashboard spec with 'customAllValue' and the fixed url fetch

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

No UI Changes -- only backend.

  • [N/A] Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • [N/A] Code follows the UI guidelines.
  • [N/A] E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

@zhuje zhuje requested a review from a team as a code owner June 24, 2026 01:06
@zhuje zhuje marked this pull request as draft June 24, 2026 14:22
@zhuje zhuje force-pushed the fix/queryparam-customallvalue branch 2 times, most recently from b2c45a2 to f796b55 Compare June 24, 2026 16:23
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje force-pushed the fix/queryparam-customallvalue branch from e742677 to 9d0d90f Compare June 24, 2026 16:24
@zhuje zhuje marked this pull request as ready for review June 24, 2026 16:38
@zhuje zhuje changed the title [WIP] BUGFIX: fix prometheus queryParam interpolation does not work for customAllValue [BUGFIX]: fix prometheus queryParam interpolation does not work for customAllValue Jun 24, 2026
const allOptionValues = options.map((o) => o.value);

const isArray = Array.isArray(varState.value);
const isCustomAllValue =

@jgbernalp jgbernalp Jun 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to identify better the customAllValue, perhaps from the variable definition propagating it in the variable provider to here, if a current selected option has no matching item in the options can be falsely identified as being the customAllValue.

try {
const regex = new RegExp(`^${varState.value}$`);
const matched = options.filter((o) => regex.test(o.value)).map((o) => o.value);
expandValues = matched.length > 0 ? matched : allOptionValues;

@jgbernalp jgbernalp Jun 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we are missing a test for the case the current all values regex matches no options, this is falling back to all options by design but is not tested.

expandValues = varState.value as string[];
} else if (isCustomAllValue) {
try {
const regex = new RegExp(`^${varState.value}$`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is an utility with better error handling. createRegexFromString

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants