Skip to content

Match StackScript usernames exactly in test_list_stackscripts - #941

Open
lyelgate wants to merge 1 commit into
linode:devfrom
lyelgate:fix/stackscripts-test-regex
Open

lyelgate wants to merge 1 commit into
linode:devfrom
lyelgate:fix/stackscripts-test-regex

Conversation

@lyelgate

@lyelgate lyelgate commented Nov 1, 2026

Copy link
Copy Markdown

📝 Description

What does this PR do and why is this change necessary?

Fixes #734.

test_list_stackscripts checked the username column with ([A-z]|[0-9])+. The range A-z also includes the six characters between Z and a ([ \ ] ^ _ `), and the pattern doesn't allow hyphens. So it accepted characters a username can't contain and rejected valid usernames such as jane-doe, which would fail the test for an account whose public StackScripts belong to a hyphenated user.

Per the API spec, usernames are 3 to 32 letters, digits, hyphens and underscores (^[a-zA-Z0-9]((?![_-]{2,})[a-zA-Z0-9-_])+[a-zA-Z0-9]$). This PR matches [A-Za-z0-9_-]+ instead. It's the only A-z range in the repository.

Line Old New
123,linode,True match match
123,john_doe,True match match
123,jane-doe,True no match match
123,ab^c,True match no match

✔️ How to Test

What are the steps to reproduce the issue or verify the changes?

The table above was checked with re.fullmatch against both patterns.

How do I run the relevant unit/integration tests?

make test-int TEST_CASE=test_list_stackscripts

This is an integration test, so it needs a Linode account. I verified the pattern itself as shown above. black and isort pass.

The username check used the range [A-z], which also matches the six
characters between Z and a ([ \ ] ^ _ `), and did not allow hyphens.
It accepted characters a username cannot contain and rejected valid
usernames such as jane-doe.

Linode usernames are letters, digits, hyphens and underscores, so
match [A-Za-z0-9_-]+ instead.

Fixes linode#734
@lyelgate
lyelgate requested review from a team as code owners November 1, 2026 11:35
@lyelgate
lyelgate requested review from psnoch-akamai and yec-akamai and removed request for a team November 1, 2026 11:35

This branch has not been deployed

No deployments
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.

[Bug]: Overly permissive regular expression range

1 participant