Skip to content

fix: disallow empty key #134

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

Merged
merged 1 commit into from
Jan 11, 2024
Merged

fix: disallow empty key #134

merged 1 commit into from
Jan 11, 2024

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented Jan 11, 2024

Disallows "" as key. This is not a breaking change, because before we had a bug where get("") would show the result of list() - so this didn't work in the first place.

Resolves https://linear.app/netlify/issue/COM-283/blobs-get-shows-unintended-api-response.

@Skn0tt Skn0tt self-assigned this Jan 11, 2024
@Skn0tt Skn0tt requested a review from a team as a code owner January 11, 2024 12:12
Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for blobs-js ready!

Name Link
🔨 Latest commit b8623f1
🔍 Latest deploy log https://app.netlify.com/sites/blobs-js/deploys/659fdb2062185000089f041b
😎 Deploy Preview https://deploy-preview-134--blobs-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Jan 11, 2024
@@ -307,6 +307,10 @@ export class Store {
}

private static validateKey(key: string) {
if (key === '') {
throw new Error('Blob key must not be empty.')
Copy link
Member

Choose a reason for hiding this comment

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

You could also make this part of the check on line 318 and adjust the message to something like:

Blob key must be a sequence of Unicode characters whose UTF-8 encoding is between 1 and 600 bytes long.

Just an idea, no strong preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's nifty - but if I were debugging this exception, I think i'd be way more confused by the words "Unicode" and "UTF-8" than necessary. Gonna keep it like it is!

@Skn0tt Skn0tt merged commit a8b4a23 into main Jan 11, 2024
@Skn0tt Skn0tt deleted the disallow-empty-key branch January 11, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants