-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(delegation-index): primary key violation #15086
Conversation
WalkthroughThe recent changes in the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant Client
participant DelegationsIndexService
participant Database
Client->>DelegationsIndexService: Request to update delegation
DelegationsIndexService->>Database: Fetch existing delegation
Database-->>DelegationsIndexService: Return existing delegation
alt Delegation exists
DelegationsIndexService->>DelegationsIndexService: Check `validTo` and `customDelegationScopes`
alt Conditions met
DelegationsIndexService->>Database: Update delegation
Database-->>DelegationsIndexService: Confirmation
else Conditions not met
DelegationsIndexService->>Client: Return error or no update needed
end
else Delegation does not exist
DelegationsIndexService->>Database: Create new delegation
Database-->>DelegationsIndexService: Confirmation
end
DelegationsIndexService-->>Client: Response
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Datadog ReportAll test runs ✅ 33 Total Test Services: 0 Failed, 32 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (3) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15086 +/- ##
==========================================
- Coverage 37.05% 37.05% -0.01%
==========================================
Files 6422 6422
Lines 130935 130935
Branches 37413 37413
==========================================
- Hits 48523 48519 -4
- Misses 82412 82416 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
LGTM🚀
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (2)
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (2)
Line range hint
464-464
: Optimize the use of spread syntax in.reduce
.Using spread syntax in the accumulator of a
.reduce
function leads to poor performance due toO(n^2)
complexity. Consider using methods like.push
to accumulate values.- return [...acc, ...delegations] + acc.push(...delegations) + return acc
Line range hint
223-224
: Use optional chaining for safer code.Consider using optional chaining to safely access nested properties. This can prevent runtime errors if some intermediate properties are
null
orundefined
.- if (existing && existing.validTo !== curr.validTo) + if (existing?.validTo !== curr.validTo)
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (1 hunks)
Additional context used
Path-based instructions (1)
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
Biome
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts
[error] 143-143: Decorators are not valid here. (parse)
Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting theunsafeParameterDecoratorsEnabled
option totrue
in your configuration file.
[error] 145-145: Decorators are not valid here. (parse)
Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting theunsafeParameterDecoratorsEnabled
option totrue
in your configuration file.
[error] 147-147: Decorators are not valid here. (parse)
Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting theunsafeParameterDecoratorsEnabled
option totrue
in your configuration file.
[error] 223-224: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 464-464: Avoid the use of spread (
...
) syntax on accumulators. (lint/performance/noAccumulatingSpread)Spread syntax should be avoided on accumulators (like those in
.reduce
) because it causes a time complexity ofO(n^2)
.
Consider methods such as .splice or .push instead.
Additional comments not posted (1)
libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts (1)
Line range hint
143-143
: Check the usage of decorators.The static analysis tool flagged potential issues with decorators. Please verify if decorators are used correctly in the context of this file, or if there's a misconfiguration in the analysis tool.
Also applies to: 145-145, 147-147
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Fix primary key violation when indexing delegations
Checklist:
Summary by CodeRabbit