fix: log when calculated top-up-amount is not a positive value#1861
Conversation
WalkthroughAdded non-fatal warning logs when computed top-up amounts are non-positive in two services: Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant DSS as DeploymentSettingService
participant Logger
Caller->>DSS: withEstimatedTopUpAmount(dseq, userId, ...)
DSS->>DSS: compute estimatedTopUpAmount
alt estimatedTopUpAmount <= 0
DSS->>Logger: warn(TOP_UP_AMOUNT_NON_POSITIVE, {estimatedTopUpAmount, dseq, userId})
end
DSS-->>Caller: result (unchanged structure)
sequenceDiagram
autonumber
actor Scheduler
participant TUMD as TopUpManagedDeploymentsService
participant Balance as BalanceCalculator
participant Logger
Scheduler->>TUMD: collectMessages(...)
TUMD->>Balance: compute balance, desiredAmount
alt desiredAmount <= 0
TUMD->>Logger: warn(TOP_UP_AMOUNT_NON_POSITIVE, {desiredAmount, dseq, address, blockRate})
end
TUMD->>Balance: reserveSufficientAmount(desiredAmount)
TUMD-->>Scheduler: prepared messages (flow unchanged)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
apps/api/src/deployment/services/deployment-setting/deployment-setting.service.ts (2)
7-7: Avoid mixing two LoggerService implementationsThis file imports LoggerService from "@src/core/providers/logging.provider" while TopUpManagedDeploymentsService uses "@akashnetwork/logging". Standardize on one to prevent divergent behaviors and config. If both are aliases, consolidate to the shared package for clarity.
Proposed change:
-import { LoggerService } from "@src/core/providers/logging.provider"; +import { LoggerService } from "@akashnetwork/logging";
85-92: Good: non-positive estimate warning; confirm consumer expectations for negativesThe warning is helpful. Verify that API consumers expect negative estimatedTopUpAmount values; otherwise consider normalizing to 0 at the return site to avoid UI confusion.
apps/api/src/deployment/services/top-up-managed-deployments/top-up-managed-deployments.service.ts (1)
91-99: Log is good; optionally skip message construction on non-positive desiredAmount and include dryRun in the logContinuing to build a message for desiredAmount <= 0 can waste work or produce invalid txs depending on downstream behavior. Optionally short-circuit and add dryRun for parity with other logs.
- if (desiredAmount <= 0) { - this.logger.warn({ - event: "TOP_UP_AMOUNT_NON_POSITIVE", - desiredAmount, - dseq: deployment.dseq, - address: deployment.address, - blockRate: deployment.blockRate - }); - } + if (desiredAmount <= 0) { + this.logger.warn({ + event: "TOP_UP_AMOUNT_NON_POSITIVE", + desiredAmount, + dseq: deployment.dseq, + address: deployment.address, + blockRate: deployment.blockRate, + dryRun: options.dryRun + }); + return; + }Also consider centralizing event names as constants/enums to avoid typos across services.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
apps/api/src/deployment/services/deployment-setting/deployment-setting.service.ts(3 hunks)apps/api/src/deployment/services/top-up-managed-deployments/top-up-managed-deployments.service.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Never use type any or cast to type any. Always define the proper TypeScript types.
Files:
apps/api/src/deployment/services/top-up-managed-deployments/top-up-managed-deployments.service.tsapps/api/src/deployment/services/deployment-setting/deployment-setting.service.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code
Files:
apps/api/src/deployment/services/top-up-managed-deployments/top-up-managed-deployments.service.tsapps/api/src/deployment/services/deployment-setting/deployment-setting.service.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: validate / validate-app
- GitHub Check: test-build
🔇 Additional comments (1)
apps/api/src/deployment/services/deployment-setting/deployment-setting.service.ts (1)
21-21: LGTM: contextual logger setupConsistent with other services and enables scoped logs.
b9da01f to
5e55d18
Compare
refs #1841
Summary by CodeRabbit