Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disallow invalid tag values #7268

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Jun 4, 2024

This PR fixes how Unleash handles tag values. Specifically, it does these things:

  1. Trims leading and trailing whitespace from tag values before inserting them into the database
  2. Updates OpenAPI validation to not allow whitespace-only and to ignore leading and trailing whitespace

Additionally, it moves the tag length constants into the constants file from the Joi tag schema file. This is because importing the values previously rendered them as undefined (probably due to a circular dependency somewhere in the system). This means that the previous values were also ignored by OpenAPI.

UI updates reflecting this wil follow.

Background

When you tag a flag, there's nothing stopping you from using an entirely empty tag or a tag with leading/trailing whitespace.

Empty tags make little sense and leading trailing whitespace differences are incredibly subtle:
image

Additionally, leading and trailing whitespace is not shown in the dropdown list, so you'd have to guess at which is the right one.
image

Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 6:26am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Jun 5, 2024 6:26am

Copy link
Contributor

github-actions bot commented Jun 4, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

This is to separate it from the responses we use. Because if your
existing tags were "invalid" based on this new validation, Unleash
shouldn't complain about it.
@thomasheartman thomasheartman merged commit 2bad98a into main Jun 5, 2024
7 checks passed
@thomasheartman thomasheartman deleted the fix/1-2454-bug-tags-can-have-whitespace-or-be-entirely-whitespace branch June 5, 2024 06:31
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