-
Notifications
You must be signed in to change notification settings - Fork 613
feat: override methods in sdk #2668
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@unkey/api": minor | ||
| --- | ||
|
|
||
| Add ratelimit override API |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -116,10 +116,10 @@ export const registerV1KeysGetVerifications = (app: App) => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| roles: dbRes.roles.map((p) => p.role.name), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| identity: dbRes.identity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: dbRes.identity.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| externalId: dbRes.identity.externalId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| meta: dbRes.identity.meta, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: dbRes.identity.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| externalId: dbRes.identity.externalId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| meta: dbRes.identity.meta, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -249,20 +249,20 @@ export const registerV1KeysGetVerifications = (app: App) => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifications[d.time] = { success: 0, rateLimited: 0, usageExceeded: 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (d.outcome) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "VALID": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // case "VALID": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifications[d.time].success += d.count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "RATE_LIMITED": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifications[d.time].rateLimited += d.count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifications[d.time].rateLimited += d.count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "USAGE_EXCEEDED": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifications[d.time].usageExceeded += d.count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifications[d.time].usageExceeded += d.count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+252
to
+260
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix broken switch statement syntax and logic There are several critical issues in the switch statement:
Apply this fix to restore proper functionality: switch (d.outcome) {
- // case "VALID":
- verifications[d.time].success += d.count;
- break;
- case "RATE_LIMITED":
-verifications[d.time].rateLimited += d.count;
-break;
- case "USAGE_EXCEEDED":
-verifications[d.time].usageExceeded += d.count;
-break;
+ case "VALID":
+ verifications[d.time].success += d.count;
+ break;
+ case "RATE_LIMITED":
+ verifications[d.time].rateLimited += d.count;
+ break;
+ case "USAGE_EXCEEDED":
+ verifications[d.time].usageExceeded += d.count;
+ break;
+ default:
+ logger.warn(`Unknown verification outcome: ${d.outcome}`);
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome[error] 253-253: Expected a default, or a case but instead found 'verifications'. Expected a default, or a case here. (parse) [error] 255-256: Expected a statement but instead found 'case "RATE_LIMITED": Expected a statement here. (parse) [error] 258-259: Expected a statement but instead found 'case "USAGE_EXCEEDED": Expected a statement here. (parse) [error] 256-257: This code is unreachable ... because this statement will break the flow of the code beforehand (lint/correctness/noUnreachable) [error] 259-260: This code is unreachable ... because this statement will break the flow of the code beforehand (lint/correctness/noUnreachable) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // really ugly hack to return an emoty array in case there wasn't a single verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // really ugly hack to return an empty array in case there wasn't a single verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // this became necessary when we switched to clickhouse, due to the different responses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Object.values(verifications).every(({ success, rateLimited, usageExceeded }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Based on the git history and code context, I can now provide a final response:
Commenting out "VALID" case appears to be unintentional
The change was introduced in commit a92f1d7 "feat: override methods in sdk" but seems to be an accidental formatting change rather than an intentional feature modification because:
verifications[d.time].success += d.count)This should be fixed by uncommenting the "VALID" case to maintain proper verification counting.
🔗 Analysis chain
Verify the intent of commenting out the "VALID" case
The "VALID" case has been commented out, which means successful verifications are not being counted. Is this intentional and related to the rate limit override API changes mentioned in the PR objectives?
Let me gather more context about this specific file and the changes around this code section.
Let me try one more verification to understand if this is part of recent changes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2152
Script:
Length of output: 922
Script:
Length of output: 14265