Conversation
📝 WalkthroughWalkthroughAdds internal helpers to sanitize action arguments and detect value presence; updates prompt generation to prefer human-readable amount fields; enriches pending actions with inferred tokenAddress; and ensures sanitized payloads (dropping network and raw variants) are used when creating or editing borrow actions. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ 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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@recipes/borrow.ts`:
- Around line 1179-1182: The current preFilledFields calculation treats empty
strings as valid values, allowing blank inputs to bypass prompts; update the
filter for preFilledArgs used in preFilledFields (derived from
pendingAction.args and network) to also exclude values that are empty strings
(e.g., value === "" or value.trim() === "" for strings) so only non-null,
non-undefined, non-empty-string entries are considered prefilled.
- Around line 425-429: The skip logic only checks result
(hasValue(result.amount)) so prefilled or skipped fields upstream still allow
their raw counterparts (e.g., amountRaw) to be prompted; update the conditions
in the block that inspects name/result to also consider
upstream/skipped/prefilled inputs by checking skipFields (or the original
prefill/initialValues) in addition to result—e.g., change the checks for
amount/amountRaw and collateralAmount/collateralAmountRaw to skip when
hasValue(result.amount) || skipFields.includes("amount") ||
hasValue(initialValues?.amount) (and the analogous checks for collateralAmount),
keeping the same name, result, skipFields and hasValue symbols to locate and
update the conditions.
- Around line 1094-1115: The current logic unconditionally infers
args.tokenAddress from market.loanToken.address and adds "tokenAddress" to
skipFields, which wrongly prevents users from selecting collateral-sensitive
tokens for actions like withdraw or collateral toggles; update the conditional
around setting args.tokenAddress and pushing "tokenAddress" so it only
auto-infers for action types where the token must be the loan token (e.g.,
BorrowActionType.BORROW, BorrowActionType.REPAY, and pool-based SUPPLY), and
ensure for isolated markets and non-supply actions (like WITHDRAW or collateral
toggles) you do not set args.tokenAddress or skip the field; adjust the checks
around market.type, actionType, market.collateralTokens, and market.loanToken
before calling promptFromSchema(actionDef.schema, skipFields) so
promptFromSchema still asks for tokenAddress when user selection is required.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
recipes/borrow.ts
| const preFilledArgs: ArgumentsDto = { ...pendingAction.args, network }; | ||
| const preFilledFields = Object.keys(preFilledArgs).filter( | ||
| (k) => preFilledArgs[k] !== undefined && preFilledArgs[k] !== null, | ||
| ); |
There was a problem hiding this comment.
Treat empty-string prefilled values as missing.
Line 1180-Line 1182 currently marks "" as prefilled, which can skip required prompts and forward invalid blanks.
Suggested fix
- const preFilledFields = Object.keys(preFilledArgs).filter(
- (k) => preFilledArgs[k] !== undefined && preFilledArgs[k] !== null,
- );
+ const preFilledFields = Object.keys(preFilledArgs).filter((k) => hasValue(preFilledArgs[k]));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@recipes/borrow.ts` around lines 1179 - 1182, The current preFilledFields
calculation treats empty strings as valid values, allowing blank inputs to
bypass prompts; update the filter for preFilledArgs used in preFilledFields
(derived from pendingAction.args and network) to also exclude values that are
empty strings (e.g., value === "" or value.trim() === "" for strings) so only
non-null, non-undefined, non-empty-string entries are considered prefilled.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
recipes/borrow.ts (1)
1192-1194:⚠️ Potential issue | 🟡 MinorUse
hasValueforpreFilledFieldsto avoid skipping prompts on empty strings.Line 1192 still treats
""as prefilled, which can suppress required prompts and forward blank values.Suggested fix
- const preFilledFields = Object.keys(preFilledArgs).filter( - (k) => preFilledArgs[k] !== undefined && preFilledArgs[k] !== null, - ); + const preFilledFields = Object.keys(preFilledArgs).filter((k) => + hasValue(preFilledArgs[k]), + );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@recipes/borrow.ts` around lines 1192 - 1194, preFilledFields currently treats empty strings as filled because it filters preFilledArgs by !== undefined && !== null; change the filtering to use the existing hasValue predicate so "" is considered empty and won't skip prompts — update the declaration of preFilledFields (which references preFilledArgs) to filter with hasValue(preFilledArgs[k]) instead of the current null/undefined checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@recipes/borrow.ts`:
- Around line 1192-1194: preFilledFields currently treats empty strings as
filled because it filters preFilledArgs by !== undefined && !== null; change the
filtering to use the existing hasValue predicate so "" is considered empty and
won't skip prompts — update the declaration of preFilledFields (which references
preFilledArgs) to filter with hasValue(preFilledArgs[k]) instead of the current
null/undefined checks.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
recipes/borrow.ts
Added
Description of new functionality, feature, or content that has been added in this pull request.
Changed
Description of the modifications made to existing functionality, feature, or content in this pull request. This could include changes to code, CI, documentation, etc.
Summary by CodeRabbit
Refactor
New Features