Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

refactor: remove policy field and update policy handling in DCA and P…#71

Merged
johnnyluo merged 1 commit into
mainfrom
update-verifier-dep
May 27, 2025
Merged

refactor: remove policy field and update policy handling in DCA and P…#71
johnnyluo merged 1 commit into
mainfrom
update-verifier-dep

Conversation

@johnnyluo

@johnnyluo johnnyluo commented May 27, 2025

Copy link
Copy Markdown
Contributor

…ayroll

Summary by CodeRabbit

  • New Features

    • Improved handling and validation of policy signatures and message hashes for enhanced security and reliability.
  • Bug Fixes

    • Corrected transaction hash comparison to ensure accurate verification during signing processes.
  • Refactor

    • Simplified the policy signature verification process for better maintainability.
    • Updated transaction signing request formats to include richer message structures.
    • Removed legacy policy field usage across the application and database for streamlined data management.
  • Chores

    • Upgraded several dependencies to their latest versions for improved stability and compatibility.
    • Updated database schema to remove obsolete policy field.

Copilot AI review requested due to automatic review settings May 27, 2025 07:35
@coderabbitai

coderabbitai Bot commented May 27, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change removes the policy field from plugin policy storage, updates related database migrations, and refactors policy signature verification to use deterministic concatenation of key fields. It also updates transaction signing request formats, defers policy JSON parsing, and upgrades several Go module dependencies.

Changes

File(s) Change Summary
api/plugin.go Refactored policy signature verification to use concatenated key fields; updated message hash comparison logic.
go.mod Upgraded multiple dependencies and updated indirect dependencies.
internal/scheduler/scheduler.go Changed policy JSON unmarshaling source from policy.Policy to policy.Recipe.
plugin/dca/dca.go Removed direct JSON unmarshaling of policy.Policy; updated signing request message structure and hash extraction.
plugin/payroll/policy.go Removed JSON unmarshaling of policy.Policy; added TODOs for future conversion from recipe.
plugin/payroll/transaction.go Removed JSON unmarshaling of policy.Policy; updated keysign request structure and removed unused fields.
scripts/dev/create_dca_policy/main.go
scripts/dev/create_payroll_policy/main.go
Removed/commented out assignment of marshaled policy JSON to the Policy field before sending requests.
storage/postgres/migrations/20250527071907_remove_policy_field.sql Migration to remove the policy column from the plugin_policies table.
storage/postgres/policy.go Removed all code handling the policy field in plugin policy database operations.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PluginServer
    participant Database

    Client->>PluginServer: POST /create_policy (no policy field)
    PluginServer->>Database: Insert policy (without policy JSON)
    Database-->>PluginServer: Confirmation
    PluginServer-->>Client: Policy created

    Client->>PluginServer: Request signature verification
    PluginServer->>PluginServer: Concatenate key fields (Recipe, PublicKey, etc.)
    PluginServer->>PluginServer: Verify signature with concatenated message
    PluginServer-->>Client: Verification result
Loading

Possibly related PRs

Suggested reviewers

  • RaghavSood

Poem

In fields of code where plugins dwell,
Old policy bytes we bid farewell.
With hashes neat and fields combined,
The signature’s path is well-defined.
Database lighter, logic clean—
A rabbit hops where bugs had been!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package session: could not load export data: no export data for "github.com/vultisig/go-wrappers/go-dkls/sessions""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package session: could not load export data: no export data for "github.com/vultisig/go-wrappers/go-dkls/sessions""

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

A refactor to remove the policy JSONB column from plugin_policies and centralize policy content in the recipe field, updating storage, migrations, scripts, plugin code, and the API accordingly.

  • Drop the DB policy column and strip out JSON marshaling/unmarshaling in the Postgres backend
  • Update dev scripts and plugin code to defer parsing of policy.Recipe (currently stubbed with TODOs)
  • Adjust API signature logic to use the recipe-based message format and bump dependency versions

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
storage/postgres/policy.go Removed raw JSON handling for policy, now uses recipe
storage/postgres/migrations/20250527071907_*.sql Migration to drop/add the policy column
scripts/dev/create_payroll_policy/main.go Commented out obsolete policy.Policy assignment
scripts/dev/create_dca_policy/main.go Commented out obsolete policy.Policy assignment
plugin/payroll/transaction.go Removed JSON unmarshal of policy.Policy, added TODOs
plugin/payroll/policy.go Removed JSON unmarshal of policy.Policy, added TODOs
plugin/dca/dca.go Removed JSON unmarshal of policy.Policy, added TODOs
internal/scheduler/scheduler.go Switched unmarshal from policy.Policy to policy.Recipe
api/plugin.go Updated SignPluginMessages and policyToMessageHex
go.mod Bumped several dependency versions
Comments suppressed due to low confidence (2)

scripts/dev/create_dca_policy/main.go:101

  • The Policy field has been removed from the struct. You need to map policyBytes into policy.Recipe so the DCA policy is passed through correctly.
policy.Policy = policyBytes

api/plugin.go:73

  • The error message prints the entire struct (req.Messages[0]) instead of its Hash. Update the format to use req.Messages[0].Hash for the got value.
return fmt.Errorf("message hash does not match transaction hash. expected %s, got %s", txHash, req.Messages[0])

Comment thread scripts/dev/create_payroll_policy/main.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/policy.go
Comment thread plugin/payroll/policy.go
Comment thread plugin/dca/dca.go
Comment thread plugin/dca/dca.go
Comment thread plugin/dca/dca.go
Comment thread plugin/dca/dca.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🔭 Outside diff range comments (3)
scripts/dev/create_payroll_policy/main.go (1)

124-130: 💡 Verification agent

🧩 Analysis chain

Verify that servers can handle missing Policy field.

The policy.Policy field assignment has been commented out, but the policyBytes variable is still created and unused. This change could cause issues if the verifier or plugin servers expect the Policy field to be populated.

Consider removing the unused policyBytes variable if it's no longer needed:

-	policyBytes, err := json.Marshal(payrollPolicy)
-	if err != nil {
-		panic(err)
-	}
-
-	fmt.Println("Payroll policy", string(policyBytes))
-	// policy.Policy = policyBytes
+	policyJson, _ := json.Marshal(payrollPolicy)
+	fmt.Println("Payroll policy", string(policyJson))

🏁 Script executed:

#!/bin/bash
# Check if there are any server-side handlers that still expect the Policy field
echo "Searching for Policy field usage in server handlers..."

# Look for Policy field access in HTTP handlers
rg -A 5 -B 5 "\.Policy" --type go

# Look for JSON unmarshaling that might expect Policy field
rg -A 5 -B 5 "json\.Unmarshal.*Policy" --type go

Length of output: 13168


Remove unused policyBytes and commented-out assignment

We searched the Go services (including HTTP handlers and JSON tags) and found no references to a Policy byte‐slice field—only PolicyID and PolicyVersion. It’s safe to drop the commented assignment, but the policyBytes variable is now unused and should be either removed or repurposed for logging.

Locations to update:

  • scripts/dev/create_payroll_policy/main.go (around lines 124–130)

Suggested diff:

-scripts/dev/create_payroll_policy/main.go:124
-   policyBytes, err := json.Marshal(payrollPolicy)
-   if err != nil {
-       panic(err)
-   }
-   fmt.Println("Payroll policy", string(policyBytes))
-   // policy.Policy = policyBytes
+scripts/dev/create_payroll_policy/main.go:124
+   policyJSON, err := json.Marshal(payrollPolicy)
+   if err != nil {
+       panic(err)
+   }
+   fmt.Println("Payroll policy", string(policyJSON))

Or, if you don’t need the JSON output for debugging, remove the marshalling block entirely.

plugin/payroll/transaction.go (1)

82-88: ⚠️ Potential issue

Potential panic on empty txs

signRequest := txs[0] will panic when there are no recipients (see earlier issue).
Guard before accessing:

if len(txs) == 0 {
    return nil, fmt.Errorf("no transactions generated")
}
plugin/dca/dca.go (1)

94-106: ⚠️ Potential issue

dcaPolicy never parsed – leads to incorrect chainID & validation errors

chainID, ok := new(big.Int).SetString(dcaPolicy.ChainID, 10) operates on an empty string because dcaPolicy is never filled. Similar issues appear throughout the file (price checks, token IDs, etc.).

Parsing the recipe is mandatory before any validation or tx generation.

♻️ Duplicate comments (2)
plugin/dca/dca.go (2)

289-291: ProposeTransactions uses empty policy – will always error or panic

totalAmount and totalOrders parse empty strings, inevitably returning errors and preventing proposal generation. Same root cause: unparsed recipe.


376-378: ValidateProposedTransactions suffers from the same uninitialized struct issue

All policy checks below rely on empty dcaPolicy; validation will incorrectly fail.

🧹 Nitpick comments (4)
storage/postgres/policy.go (1)

18-33: Column order coupling – consider naming columns explicitly in Scan

The SELECT list and Scan arguments rely on positional order. If a future migration re-orders columns the code will silently mis-map values.

A safer pattern is to give each selected column an alias that matches the struct field order:

SELECT id,
       public_key,
       plugin_id,
       plugin_version,
       policy_version,
       signature,
       active,
       recipe
FROM plugin_policies
WHERE id = $1;

and keep the same order in Scan, or use pgx.RowToStructByName.

Not mandatory, but lowers maintenance risk.

plugin/payroll/transaction.go (2)

44-54: Indexing parallel slices is brittle – prefer struct of recipient+token

payrollPolicy.ChainID[i], payrollPolicy.TokenID[i] assume all three slices are the same length and aligned.
Consider modelling each payment as a struct {ChainID, TokenID, Recipient} and looping over that slice to avoid alignment bugs.


60-74: Verify new KeysignMessage construction – field types & duplication

  1. Chain: vcommon.Ethereum – confirm that the type matches KeysignMessage.Chain (string vs enum).
  2. You set PolicyID twice: once inside the embedded KeysignRequest, again in the outer PluginKeysignRequest. Duplication invites inconsistencies.
  3. Removed DerivePath/IsECDSA; ensure downstream services no longer rely on them.
api/plugin.go (1)

72-74: Good change, but fix the error message for consistency.

The hash comparison logic is correct and aligns with the updated message structure. However, the error message still references req.Messages[0] which may now display the entire struct instead of just the hash.

Consider updating the error message for clarity:

-	if txHash != req.Messages[0].Hash {
-		return fmt.Errorf("message hash does not match transaction hash. expected %s, got %s", txHash, req.Messages[0])
-	}
+	if txHash != req.Messages[0].Hash {
+		return fmt.Errorf("message hash does not match transaction hash. expected %s, got %s", txHash, req.Messages[0].Hash)
+	}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e774351 and 7b60041.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • api/plugin.go (3 hunks)
  • go.mod (2 hunks)
  • internal/scheduler/scheduler.go (1 hunks)
  • plugin/dca/dca.go (5 hunks)
  • plugin/payroll/policy.go (3 hunks)
  • plugin/payroll/transaction.go (3 hunks)
  • scripts/dev/create_dca_policy/main.go (0 hunks)
  • scripts/dev/create_payroll_policy/main.go (1 hunks)
  • storage/postgres/migrations/20250527071907_remove_policy_field.sql (1 hunks)
  • storage/postgres/policy.go (4 hunks)
💤 Files with no reviewable changes (1)
  • scripts/dev/create_dca_policy/main.go
🔇 Additional comments (5)
go.mod (1)

8-8:

Details

✅ Verification successful

Verify security and validity of updated dependencies.

The dependency updates include critical cryptographic libraries and Ethereum-related packages. Ensure these versions are secure and free from known vulnerabilities.

Also applies to: 21-21, 29-32, 35-35


🏁 Script executed:

#!/bin/bash
# Check for security advisories for the main updated dependencies
echo "Checking security advisories for updated dependencies..."

for pkg in "ethereum/go-ethereum" "consensys/gnark-crypto" "crate-crypto/go-eth-kzg"; do
  echo "=== Checking $pkg ==="
  gh api graphql -f query="
  {
    securityVulnerabilities(first: 5, ecosystem: GO, package: \"$pkg\") {
      nodes {
        advisory {
          summary
          severity
          publishedAt
        }
        vulnerableVersionRange
        firstPatchedVersion {
          identifier
        }
      }
    }
  }" 2>/dev/null || echo "Unable to check security advisories for $pkg"
done

Length of output: 1800


🌐 Web query:

Are there any known security vulnerabilities in ethereum/go-ethereum v1.15.11?

💡 Result:

As of May 27, 2025, there are no known security vulnerabilities in Ethereum's go-ethereum (Geth) version 1.15.11. The latest release, v1.15.11, is a maintenance update that addresses issues with log and transaction indexing. Notably, it resolves a stall condition in eth_getTransactionByHash and fixes two bugs in the new log indexer. Upgrading to this release is recommended to improve RPC performance. (newreleases.io)

Previous vulnerabilities, such as CVE-2025-24883, which allowed a remote attacker to perform a denial of service (DoS) attack via specially crafted p2p messages, were addressed in earlier versions. Specifically, this vulnerability was fixed in version 1.14.13. (tenable.com)

For the most current information on security advisories, you can refer to the official Ethereum GitHub repository's security advisories page. (github.com)

Stock market information for Ethereum (ETH)

  • Ethereum is a crypto in the CRYPTO market.
  • The price is 2591.74 USD currently with a change of 7.79 USD (0.00%) from the previous close.
  • The intraday high is 2599.37 USD and the intraday low is 2526.56 USD.

Citations:


No security vulnerabilities found in updated dependencies

We checked the main updated Go modules via GitHub’s Security Advisories API and public release notes:

  • ethereum/go-ethereum v1.15.11: no open CVEs (maintenance update with log-indexing and RPC fixes)
  • consensys/gnark-crypto (latest commit): no reported vulnerabilities
  • crate-crypto/go-eth-kzg v1.3.0: no known security advisories

Please continue to monitor the upstream security pages (e.g. github.com/ethereum/go-ethereum/security/advisories) for future updates.

storage/postgres/migrations/20250527071907_remove_policy_field.sql (1)

1-11:

Details

❓ Verification inconclusive

Well-structured migration for policy field removal.

The migration properly removes the policy column with appropriate safety checks using IF EXISTS and IF NOT EXISTS clauses. The DOWN migration correctly restores the column with proper JSONB type and default value.


🏁 Script executed:

#!/bin/bash
# Verify that all database queries have been updated to remove policy column references
echo "Checking for remaining references to policy column in database queries..."

# Look for SQL queries that might still reference the policy column
rg -i "select.*policy|policy.*from|insert.*policy|update.*policy" --type go

# Look for struct fields that might map to the policy column
rg "Policy.*\`.*policy\`|policy.*\`.*Policy\`" --type go

Length of output: 5253


Confirm removal of policy column references

The migration correctly drops the policy column (and restores it in the Down step) with safe IF EXISTS/IF NOT EXISTS guards. However, automated grep for SQL references was inconclusive—matches include policy_version and method names rather than the JSONB column itself. Please manually verify that no code still touches the dropped column:

• storage/postgres/policy.go – inspect INSERT/UPDATE queries for stray policy references
• storage/db.go – methods InsertPluginPolicyTx, UpdatePluginPolicyTx
• service/policy.go – InsertPolicy and UpdatePolicy flows
• storage/postgres/time_trigger.go – joins or filters on policy_id
• plugin/dca/dca.go – calls to UpdatePluginPolicyTx
• internal/scheduler/scheduler.go – UpdateTriggerStatus
• api/plugin.go & api/server.go – endpoints handling plugin policies

plugin/payroll/policy.go (1)

68-70:

Details

❌ Incorrect review comment

Destination address compared to TokenID looks wrong

txDestination (the contract or recipient address the TX is sent to) is compared with payrollPolicy.TokenID[i].
From the naming this looks like a token contract address, not the recipient’s address. The in-code TODO confirms the doubt.

Please re-confirm the business rule. Most ERC-20 payroll flows:

  1. to = token contract
  2. ABI call arg 0 = recipient

If so, the check here should probably verify recipientAddress rather than tokenID, or at least compare txDestination to a single contract address, not one per recipient.


🏁 Script executed:

#!/bin/bash
# Locate the PayrollPolicy struct definition and TokenID field
grep -R "type PayrollPolicy" -n plugin/payroll/policy.go
grep -R "TokenID" -n plugin/payroll/policy.go

# Show the first 200 lines for context (including function containing lines 68-70)
sed -n '1,200p' plugin/payroll/policy.go

Length of output: 5126


Comparing txDestination to TokenID is intentional

The PayrollPolicy struct defines a one-to-one mapping between TokenID[i] and Recipients[i] (enforced by the len(TokenID) == len(Recipients) check). In an ERC-20 payroll flow, you do indeed need to confirm that the transaction’s to field matches the expected token contract (per recipient) before unpacking and validating the recipient argument.

The lingering // todo : why we compare to tokenId… comment is now outdated and can be removed or updated to explain that this check ensures the TX targets the correct token contract for each recipient.

Likely an incorrect or invalid review comment.

api/plugin.go (2)

324-324: Good simplification of the function signature.

Removing the unused update parameter simplifies the API and aligns with the new deterministic policy message generation approach.


372-386: Excellent refactor to deterministic policy message generation.

This change significantly improves the policy signature verification approach:

Benefits:

  • Deterministic: Same policy always produces the same message bytes, eliminating JSON serialization inconsistencies
  • Secure: Validates against delimiter injection attacks by rejecting fields containing "#"
  • Simplified: Removes complexity of JSON marshaling and hex encoding
  • Minimal: Only includes essential fields needed for signature verification

Security Analysis:

  • The delimiter "#" is unlikely to appear in legitimate policy fields
  • Input validation prevents signature tampering via delimiter injection
  • Direct byte return eliminates encoding/decoding vulnerabilities

The field selection (Recipe, PublicKey, PolicyVersion, PluginVersion) appropriately covers the core policy identity without including mutable metadata.

}

if err := json.Unmarshal(policy.Policy, &policySchedule); err != nil {
if err := json.Unmarshal([]byte(policy.Recipe), &policySchedule); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify Recipe field contains expected schedule structure.

The change from policy.Policy to policy.Recipe for JSON unmarshaling aligns with the policy field removal. However, ensure that the Recipe field contains the schedule information in the expected JSON structure.

Additionally, consider adding validation to ensure the Recipe field contains valid schedule JSON:

 if err := json.Unmarshal([]byte(policy.Recipe), &policySchedule); err != nil {
-    return nil, fmt.Errorf("failed to parse policy schedule: %w", err)
+    return nil, fmt.Errorf("failed to parse policy schedule from recipe: %w", err)
 }

🏁 Script executed:

#!/bin/bash
# Verify that Recipe field is properly populated and contains schedule information
echo "Checking Recipe field usage and structure..."

# Look for where Recipe field is set/populated
rg -A 10 -B 5 "Recipe.*=" --type go

# Look for Recipe field in struct definitions
rg -A 5 -B 5 "Recipe.*string|Recipe.*\[\]byte" --type go

# Check for any remaining uses of policy.Policy field
rg -A 5 -B 5 "policy\.Policy" --type go

Length of output: 4629


Verify Recipe JSON Structure and Update Error Handling

I’ve confirmed that:

  • storage/postgres/policy.go populates policy.Recipe (no remaining policy.Policy references).
  • vtypes.PluginPolicy.Recipe is defined as a string and passed through api/plugin.go.
  • In internal/scheduler/scheduler.go, you correctly unmarshal policy.Recipe into policySchedule.

Recommended fixes:

  • Improve the error message when unmarshaling the recipe, to clarify the source.
  • (Optional) Validate that policySchedule.Schedule is non-nil before accessing its fields.

Suggested diff in internal/scheduler/scheduler.go:

 if err := json.Unmarshal([]byte(policy.Recipe), &policySchedule); err != nil {
-    return nil, fmt.Errorf("failed to parse policy schedule: %w", err)
+    return nil, fmt.Errorf("failed to parse schedule from recipe: %w", err)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if err := json.Unmarshal([]byte(policy.Recipe), &policySchedule); err != nil {
if err := json.Unmarshal([]byte(policy.Recipe), &policySchedule); err != nil {
return nil, fmt.Errorf("failed to parse schedule from recipe: %w", err)
}
🤖 Prompt for AI Agents
In internal/scheduler/scheduler.go at line 194, improve the error handling for
unmarshaling policy.Recipe by enhancing the error message to specify that the
failure occurred while parsing the Recipe JSON. Additionally, after
unmarshaling, add a validation step to check that the resulting
policySchedule.Schedule is not nil before accessing its fields, returning a
clear error if the schedule data is missing or invalid.

Comment thread plugin/payroll/policy.go
Comment thread plugin/payroll/policy.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/payroll/transaction.go
Comment thread plugin/dca/dca.go

@RaghavSood RaghavSood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for the todos

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants