Skip to content

feat: added new middleware to validate request query values#3993

Merged
joe-elliott merged 4 commits intografana:mainfrom
javiermolinar:query-validator-middleware
Aug 22, 2024
Merged

feat: added new middleware to validate request query values#3993
joe-elliott merged 4 commits intografana:mainfrom
javiermolinar:query-validator-middleware

Conversation

@javiermolinar
Copy link
Copy Markdown
Contributor

@javiermolinar javiermolinar commented Aug 22, 2024

What this PR does:
It adds a new middleware to centralize query validations. For now, it checks if a traceQL is valid. If not it returns a 400 error code.

For metrics_query_range and metrics_query the validation is done before the middleware is executed since it's required to compile the TraceQL query to create the combiner. In these two places, we can switch from a 500 error code to a 400 one.

Which issue(s) this PR fixes:
Fixes #3990

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Copy Markdown
Collaborator

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

nice! let's add a simple e2e test to confirm we get a 400 back.

nit: rename query_validator_middleware.go to async_query_validator.go to match the other async pipeline items

@javiermolinar
Copy link
Copy Markdown
Contributor Author

I clicked on close by mistake :P

@joe-elliott joe-elliott merged commit 8a0b0e7 into grafana:main Aug 22, 2024
@javiermolinar javiermolinar deleted the query-validator-middleware branch August 23, 2024 07:20
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.

[TraceQL] Invalid regex reported as 500

2 participants