Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
📝 WalkthroughWalkthroughThis pull request introduces functionality to use default prefix and byte length when creating keys via the API. The changes span across three files: a test file for key creation, the key creation route, and the client-side key creation component. The primary focus is on implementing default values for key generation when specific parameters are not provided, drawing from the keyAuth table's stored defaults. Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (17)
🔇 Additional comments (2)
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Oguzhan Olguncu it’s not a huge deal but this removes all test coverage for the case where there isn’t a a default, which is the most common you can just use |
|
From Oguzhan Olguncu ‣ :ack: I didn't know what to do just put it there. Sounds good. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
apps/api/src/routes/v1_keys_createKey.happy.test.ts (1)
39-92: Test coverage looks good, consider adding edge cases.The test effectively validates the default prefix and bytes functionality. However, consider adding these test cases:
- When keyAuth returns null for both defaults
- When keyAuth returns invalid values
- When the API query fails
Would you like me to generate the additional test cases?
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/client.tsx (2)
88-92: Consider simplifying the validation condition.The nested condition checks could be flattened for better readability.
Consider this alternative:
- if ( - values.limitEnabled && - values.limit?.refill?.interval !== "none" && - !values.limit?.refill?.amount - ) { + const shouldValidateRefillAmount = values.limitEnabled && values.limit?.refill?.interval !== "none"; + if (shouldValidateRefillAmount && !values.limit?.refill?.amount) {
99-99: Consider adding a comment for the empty line.The empty line separates validation logic from cleanup logic, but this separation could be more explicit.
Add a comment to clarify the logical separation:
+ // Clean up form values based on enabled features
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/api/src/pkg/testutil/harness.ts(2 hunks)apps/api/src/routes/v1_keys_createKey.happy.test.ts(2 hunks)apps/api/src/routes/v1_keys_createKey.ts(3 hunks)apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/client.tsx(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: Test Packages / Test ./packages/rbac
- GitHub Check: Test Packages / Test ./packages/nextjs
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./packages/api
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: Test Packages / Test ./internal/hash
- GitHub Check: Test API / API Test Local
- GitHub Check: Test Agent Local / test_agent_local
- GitHub Check: Build / Build
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
apps/api/src/pkg/testutil/harness.ts (2)
20-21: LGTM! Well-defined constants for test data.The constants are appropriately named and have reasonable values for testing purposes.
316-317: LGTM! Consistent usage of default values.The constants are correctly used to initialize the test data, maintaining consistency across the test suite.
apps/api/src/routes/v1_keys_createKey.ts (2)
346-352: LGTM! Efficient database query for default values.The query is well-optimized:
- Uses
findFirst()for single record retrieval- Selects only required columns using empty object
- Properly handles deletedAt check
363-364: LGTM! Robust fallback mechanism for default values.The code gracefully handles default values with a clear precedence:
- Request-provided values
- Database defaults
- Hardcoded fallback (16 bytes)
|
thanks |
instead of this, you just update it with your defaults |
What does this PR do?
Fixes #2814
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit
Tests
Improvements