Skip to content

Comments

fix: add validation to reject leading/trailing whitespace in target field#1575

Merged
VikaCep merged 3 commits intomainfrom
fix/trailing-space-target
Feb 3, 2026
Merged

fix: add validation to reject leading/trailing whitespace in target field#1575
VikaCep merged 3 commits intomainfrom
fix/trailing-space-target

Conversation

@VikaCep
Copy link
Contributor

@VikaCep VikaCep commented Feb 2, 2026

Summary

Problem

A customer reported that after duplicating a browser check, the dashboard showed no metrics even though the check was running successfully. Investigation revealed:

  1. The check was saved with a trailing space in the Instance field: "FRANCE " instead of "FRANCE"
  2. Metrics were generated with instance="FRANCE " (with trailing space)
  3. When viewing the dashboard, URL parameter handling strips trailing whitespace: var-instance=FRANCE
  4. The probe variable query sm_check_info{instance="$instance"} uses "FRANCE" (no space)
  5. No match -> empty probe dropdown -> dashboard shows "N/A" for all metrics

The main Checks list page displayed data correctly because it queries metrics directly without the URL variable interpolation.

Solution

Add validation to show an error when the target field contains leading or trailing whitespace:

"Target cannot have leading or trailing whitespace"

This approach:

  • Forces users to manually fix the whitespace, making them aware of the change
  • Avoids silently transforming values which could break Terraform configs or metric continuity
  • Matches the pattern used by jobSchema for rejecting invalid characters
image

@VikaCep VikaCep self-assigned this Feb 2, 2026
@VikaCep VikaCep force-pushed the fix/trailing-space-target branch from a8089ef to 03129dc Compare February 2, 2026 19:50
@VikaCep VikaCep changed the title fix: trim target field whitespace to prevent metric label mismatches fix: add validation to reject leading/trailing whitespace in target field Feb 2, 2026
@VikaCep VikaCep marked this pull request as ready for review February 2, 2026 19:52
@VikaCep VikaCep requested a review from a team as a code owner February 2, 2026 19:52
@VikaCep VikaCep requested review from ckbedwell and g3john and removed request for a team February 2, 2026 19:52
Copy link
Contributor

@g3john g3john left a comment

Choose a reason for hiding this comment

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

Awesome! What if we just trimmed the value for them, would that cause unexpected results?

@VikaCep
Copy link
Contributor Author

VikaCep commented Feb 3, 2026

Awesome! What if we just trimmed the value for them, would that cause unexpected results?

I thought about removing the trailing whitespaces automatically on save, but in the end I decided to display a validation error message instead, because when you change job/target values (unique identifiers for a check) we lose continuity on metrics, so I didn't want that change to happen without customers noticing when they change a different check value.

For this particular customer I did suggest them to remove the whitespace themselves to fix their issue.

@github-actions github-actions bot added the fix A fix applied to the application. label Feb 3, 2026
@VikaCep VikaCep requested a review from g3john February 3, 2026 15:18
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Script size changes

Name +/- Main This PR Outcome
[263.js] = 1,715.58 kB 1,715.54 kB
[854.js] New file - 799.86 kB
[datasource/module.js] = 25.00 kB 25.00 kB
[692.js] = 20.56 kB 20.56 kB
[663.js] = 5.82 kB 5.82 kB
[module.js] = 4.90 kB 4.90 kB
[234.js] Deleted file 805.52 kB -

Totals

Name +/- Main This PR Outcome
[Scripts] -0.22% 2,577.39 kB 2,571.69 kB
[Non-script Assets] = 2,675.38 kB 2,675.38 kB
[All] -0.11% 5,252.76 kB 5,247.07 kB

Generated by 🚫 dangerJS against 4ff7d7f

Copy link
Contributor

@g3john g3john left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@ckbedwell ckbedwell left a comment

Choose a reason for hiding this comment

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

I'm fine with this but this is a scenes bug as far as I'm concerned (all the more reason to drop it 😬)

You could end up in a situation where a user was managing a check via the UI and Terraform/API and you get two different validations.

It's pretty edge-casey but as this arose from an escalation originally it's not out of the realm of possibility.

@VikaCep
Copy link
Contributor Author

VikaCep commented Feb 3, 2026

Even if this is a scenes bug when forming the dashboard URL, I think trailing whitespaces shouldn’t be allowed in job/target fields as it causes confusing scenarios that are hard to spot.
I think the API/Terraform should enforce this same behavior, which means also adding this validation on their side.

@VikaCep VikaCep merged commit 63db3ff into main Feb 3, 2026
36 checks passed
@VikaCep VikaCep deleted the fix/trailing-space-target branch February 3, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix applied to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants