fix: add defensive checks in storage resolvers instead of non-null assertions#965
Open
pyramation wants to merge 1 commit intomainfrom
Open
fix: add defensive checks in storage resolvers instead of non-null assertions#965pyramation wants to merge 1 commit intomainfrom
pyramation wants to merge 1 commit intomainfrom
Conversation
…sertions Replace cdn! and credential! non-null assertions with explicit error messages in both bucket-provisioner-resolver.ts and presigned-url-resolver.ts. If CDN env vars are missing, the resolvers now throw clear errors explaining which variables to set, instead of silently passing undefined to S3 clients.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
cdn!and credential!non-null assertions with explicit guard clauses and actionable error messages in bothbucket-provisioner-resolver.tsandpresigned-url-resolver.ts.Previously, if CDN env vars were missing, these resolvers would silently pass
undefinedinto the S3 client, producing cryptic errors deep in the AWS SDK. Now they throw early with messages that name the specific missing config.Both resolvers are lazy (called on first storage operation, not at startup), so servers that don't use storage features are unaffected.
Review & Testing Checklist for Human
AWS_ACCESS_KEY,AWS_SECRET_KEY,CDN_BUCKET_NAME. Confirm these match the actual env var names that feed intogetEnvOptions().cdn. If the real names differ (e.g.CDN_AWS_ACCESS_KEY), the error messages will be misleading.Notes
bucket-provisioner-resolver.tsintentionally does not check forbucketName(it doesn't use one — bucket names are resolved per-row from the database).presigned-url-resolver.tsadds an additionalbucketNamecheck since it requires a default bucket for signing URLs.!assertions, so existing behavior is preserved when config is present.Link to Devin session: https://app.devin.ai/sessions/4c882ba2dfbf4045adf85fb83cde6f77
Requested by: @pyramation