feat: enhance deployment reader service#2731
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughUpdated test docs to state applications/packages use Vitest or are migrating from Jest and restored a Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant DeploymentReaderService as DR
participant WalletService as Wallet
participant AuthProvider as Auth
participant ProviderAPI as Provider
Client->>DR: request deployments list
DR->>Wallet: getWalletByUserId(userId)
Wallet-->>DR: wallet (owner, credentials)
DR->>DR: map deployments → ListDeploymentsItem[]
DR->>Auth: toProviderAuth(wallet, provider)
Auth-->>DR: providerAuth
loop per lease (controlled concurrency)
DR->>Provider: getLeaseStatus(leaseKey, providerAuth)
Provider-->>DR: leaseStatus or error
end
DR-->>Client: return deployments with lease objects (status populated when available)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.claude/instructions/general-projects-description.manual.md:
- Around line 90-110: The Tech Stack "Testing" bullet currently states only
"Jest" which conflicts with the migration note showing both Jest and Vitest;
update the Tech Stack "Testing" line (the existing "Testing: Jest ..." phrase)
to mention both Jest and Vitest (e.g., "Testing: Jest (legacy) and Vitest
(migrating)") so it matches the section that lists Vitest projects and Jest
projects and removes the contradiction.
🧹 Nitpick comments (1)
apps/api/src/deployment/services/deployment-reader/deployment-reader.service.ts (1)
145-175: Guard against missing provider auth to avoid noisy failures.
auth!assumesproviderAuthMaphas an entry. IftoProviderAuthfails, each lease will throw and log a generic failure, masking the root cause. Consider short‑circuiting when auth is missing.🛠️ Suggested guard
- const auth = providerAuthMap.get(lease.id.provider); - const status = await this.providerService.getLeaseStatus(lease.id.provider, lease.id.dseq, lease.id.gseq, lease.id.oseq, auth!); + const auth = providerAuthMap.get(lease.id.provider); + if (!auth) { + this.logger.warn({ + event: "LEASE_STATUS_AUTH_MISSING", + provider: lease.id.provider, + dseq: lease.id.dseq, + gseq: lease.id.gseq, + oseq: lease.id.oseq + }); + statusMap.set(key, null); + return; + } + const status = await this.providerService.getLeaseStatus(lease.id.provider, lease.id.dseq, lease.id.gseq, lease.id.oseq, auth); statusMap.set(key, status);
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2731 +/- ##
==========================================
+ Coverage 51.77% 52.09% +0.31%
==========================================
Files 1045 1043 -2
Lines 27447 27456 +9
Branches 6340 6340
==========================================
+ Hits 14211 14302 +91
+ Misses 12809 12681 -128
- Partials 427 473 +46
🚀 New features to boost your workflow:
|
fad50fe to
4e75e63
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.claude/instructions/general-projects-description.manual.md:
- Line 90: Update the sentence "All applications and packages use **vitest** for
unit testing or are moving from jest." to use proper capitalization and tighter
wording: change to something like "All applications and packages use Vitest for
unit testing or are migrating from Jest." Locate the original sentence (the
phrase starting "All applications and packages...") and replace it with the
corrected capitalization and phrasing.
In
`@apps/api/src/deployment/services/deployment-reader/deployment-reader.service.ts`:
- Around line 149-165: The provider prefetch currently lets a single
toProviderAuth failure abort the entire PromisePool; wrap each call to
this.providerService.toProviderAuth inside its own try/catch in the
PromisePool.for(uniqueProviders) loop and store either the auth object or a
sentinel (null/undefined) in providerAuthMap so failures are isolated; then, in
the activeLeases PromisePool.for(activeLeases) loop, check
providerAuthMap.get(lease.id.provider) before calling
this.providerService.getLeaseStatus and if auth is missing, set
statusMap.set(key, null) (or otherwise handle as a degraded result) instead of
calling getLeaseStatus, preserving the original per-lease null-on-failure
behavior and preventing a single provider-auth error from aborting the whole
listing flow.
apps/api/src/deployment/services/deployment-reader/deployment-reader.service.ts
Outdated
Show resolved
Hide resolved
apps/api/src/deployment/services/deployment-reader/deployment-reader.service.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com>
64e5b9c to
c7fd772
Compare
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@apps/api/src/deployment/services/deployment-reader/deployment-reader.service.ts`:
- Around line 149-165: The prefetch of provider auth in
PromisePool.for(uniqueProviders) must guard against failures: wrap each
this.providerService.toProviderAuth({ walletId: wallet.id, provider },
["status"]) call in try-catch and on error set providerAuthMap.set(provider,
null) instead of letting the pool reject; update providerAuthMap's value type to
allow null. Then, before calling this.providerService.getLeaseStatus in the
activeLeases pool, retrieve auth from providerAuthMap and skip (or set
statusMap.set(key, null)) when auth is null/undefined instead of using the
unsafe non-null assertion auth!; ensure statusMap stores null for skipped
entries so downstream code can handle missing auth.
…ment response structurex
Rename DeploymentListItemSchema to DeploymentLeaseListItemSchema per reviewer suggestion and revert auto-generated doc changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
akash-network/support#415
Summary by CodeRabbit
Documentation
Bug Fixes / API Changes