Skip to content

Conversation

@irshadaj
Copy link
Contributor

@irshadaj irshadaj commented Feb 26, 2024

Description

Whitespaces in asset group tags conflict with delimiters in the "system_group" properties. This MR adds a check to disallow spaces in the tags field when creating an asset group. It also adds a database migration to update any existing asset group tags and trim the whitespace out.

How Has This Been Tested?

Added unit test for validation
Manual test for database migration

Screenshots (if appropriate):

Set up the database with one asset group containing a space in the tag
before

Ran the update to remove spaces
update

Verified that the spaces are removed from id=3
after

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Documentation updates are needed, and have been made accordingly.
  • I have added and/or updated tests to cover my changes.
  • All new and existing tests passed.
  • My changes include a database migration.

@irshadaj irshadaj self-assigned this Feb 26, 2024
@irshadaj irshadaj force-pushed the assetgroup_tag_validations branch 2 times, most recently from 06ead89 to be6a9fb Compare February 27, 2024 16:32
@irshadaj irshadaj force-pushed the assetgroup_tag_validations branch from 36bac5a to d017a4e Compare February 27, 2024 17:56
Copy link
Contributor

@zinic zinic left a comment

Choose a reason for hiding this comment

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

Changes look good to me!

@irshadaj irshadaj merged commit 7f7d5c5 into main Feb 27, 2024
@irshadaj irshadaj deleted the assetgroup_tag_validations branch February 27, 2024 19:54
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024

if err := api.ReadJSONRequestPayloadLimited(&createRequest, request); err != nil {
api.WriteErrorResponse(request.Context(), api.BuildErrorResponse(http.StatusBadRequest, err.Error(), request), response)
} else if strings.Contains(createRequest.Tag, " ") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Quick question: should we disallow all forms of whitespace? It seems like it may be a good idea just to be safe. We'd probably use a regex to test for any whitespace character, rather than enumerate whitespace checks manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I'll add this in a follow up MR.

Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to make this v5.8.0 due to the next version definitely being a feature update

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants