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

Validation regex pattern for branch_label display default values in Auspice config JSON is too strict #1661

Open
huddlej opened this issue Nov 7, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@huddlej
Copy link
Contributor

huddlej commented Nov 7, 2024

Current Behavior

For seasonal flu builds, we need to annotate alternate clade labels including one called proposed_subclade. We want to show these proposed subclades by default in some analyses, so we need to set the branch_label key in the Auspice config JSON's display_defaults to the proposed_subclade field.

When I do this, augur export v2 fails during validation of the Auspice config JSON with the following error:

.display_defaults.branch_label "proposed_subclade" failed pattern validation for "^(none|[a-zA-Z0-9]+)$"

Expected behavior

Validation should allow hyphens, underscores, and spaces in the branch label. For example, proposed_subclade, proposed-subclade, and Proposed subclade are all valid branch labels for the final Auspice JSON, but they are only disallowed when selected as display defaults.

Possible solution

Update the regex in the Auspice config JSON schema to be: ^(none|[-_ a-zA-Z0-9]+)$.

@huddlej huddlej added the bug Something isn't working label Nov 7, 2024
huddlej added a commit to nextstrain/seasonal-flu that referenced this issue Nov 7, 2024
Use subclade as default branch label in private builds, since Augur's
validation of the Auspice config JSON doesn't allow default branch
labels to have spaces, underscores, or hyphens [1].

[1] nextstrain/augur#1661
@jameshadfield
Copy link
Member

jameshadfield commented Nov 7, 2024

The display_defaults regex should match the regex of allowed keys for labels in the main schema:

"^(none|[a-zA-Z0-9]+)$" # current display_default.branch_label
"^[a-zA-Z0-9]+$": {     # currently allowed keys for labels as set on node.branch_attrs

which was the intention described in the commit message which updated the display default. (The addition of none in the former regex is nice as a hint, but we also should ensure you can't have a label key of "none"!)

However these regexes are overly restrictive - Auspice can (I think) display any string as label names/values:

image

Although the URL query may need some attention -- the above is ?branchLabel=[key] _ → ⁰ anything goes%3F (auspice correctly loads this from URL state, but I suspect it's invalid in some sense).

So I think the issue here requires a few things:

  • decide what values you want to allow in auspice, potentially dictated by any URL query constraints
  • Update the two regexes in the (separate) JSON schemas in augur
  • Disallow none as a valid label key

@huddlej
Copy link
Contributor Author

huddlej commented Nov 8, 2024

decide what values you want to allow in auspice, potentially dictated by any URL query constraints

I'd vote for at least hyphen, underscore, and spaces to be added to what's supported now. Is there any reason not to allow anything besides none, though? The URL encoding shouldn't be an issue...

@tsibley
Copy link
Member

tsibley commented Nov 12, 2024

☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants