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

refactor: clean up unused plugin policy methods and update return typ…#116

Merged
garry-sharp merged 3 commits into
mainfrom
refactor-return-type
Jul 4, 2025
Merged

refactor: clean up unused plugin policy methods and update return typ…#116
garry-sharp merged 3 commits into
mainfrom
refactor-return-type

Conversation

@johnnyluo

@johnnyluo johnnyluo commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

…es in fees handling

Summary by CodeRabbit

  • Refactor

    • Improved resource cleanup and error handling for API methods related to fee history.
    • Enhanced consistency in return values and pointer usage for API responses.
    • Cleaned up code by removing unused comments and debug logging statements.
    • Updated code comments for improved clarity and readability.
  • Bug Fixes

    • Ensured proper closure of HTTP response bodies to prevent resource leaks.

Copilot AI review requested due to automatic review settings July 4, 2025 07:05
@coderabbitai

coderabbitai Bot commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes primarily update internal/verifierapi/fees.go by cleaning up commented code, adding the PolicyId field to the FeeHistoryDto struct, and altering method signatures to return pointers for consistency. Additionally, resource management is improved with deferred response body closure and error logging. Comments in internal/verifierapi/verifierapi.go are reformatted for clarity.

Changes

File(s) Change Summary
internal/verifierapi/fees.go Removed commented-out code, added PolicyId to FeeHistoryDto, changed API methods to return pointers, improved error/resource handling, and removed debug logs.
internal/verifierapi/verifierapi.go Reformatted block comments to single-line comments for struct and type documentation.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant VerifierApi
  participant HTTPServer

  Client->>VerifierApi: GetPluginPolicyFees(policyId)
  VerifierApi->>HTTPServer: HTTP GET /fees/{policyId}
  HTTPServer-->>VerifierApi: FeeHistoryDto (with PolicyId)
  VerifierApi-->>Client: *FeeHistoryDto or error

  Client->>VerifierApi: GetPublicKeysFees(ecdsaPublicKey)
  VerifierApi->>HTTPServer: HTTP GET /fees/publickey/{ecdsaPublicKey}
  HTTPServer-->>VerifierApi: FeeHistoryDto (with PolicyId)
  VerifierApi-->>Client: *FeeHistoryDto or error

  Client->>VerifierApi: GetAllPublicKeysFees()
  VerifierApi->>HTTPServer: HTTP GET /fees/all
  HTTPServer-->>VerifierApi: map[string]FeeHistoryDto
  VerifierApi-->>Client: map[string]FeeHistoryDto or error
Loading

Possibly related PRs

  • 🎨 Fee log cleanup #112: Modifies the same functions in internal/verifierapi/fees.go, removing debug logging and updating error handling, directly relating to this PR's fee API cleanup.

Poem

A rabbit hopped through code so neat,
Tidying fees and closing each seat.
Policy IDs now hop in line,
Pointers and logs all looking fine.
With comments trimmed and errors caught,
The warren’s APIs are robustly wrought!
🐇✨

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""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d4b958 and af596ec.

📒 Files selected for processing (1)
  • internal/verifierapi/fees.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/verifierapi/fees.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ 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

Clean up unused plugin policy methods and enhance fees handling by updating return types and ensuring proper resource cleanup

  • Removed commented-out plugin policy method stubs
  • Changed fees API methods to return pointers and added deferred response.Body.Close()
  • Reformatted comments in verifierapi.go for consistency

Reviewed Changes

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

File Description
internal/verifierapi/verifierapi.go Replaced block comments with inline comments and updated struct documentation
internal/verifierapi/fees.go Deleted unused plugin policy methods, refactored return types to pointers, and added deferred closing of HTTP response bodies
Comments suppressed due to low confidence (1)

internal/verifierapi/fees.go:23

  • Field PolicyId should be renamed to PolicyID to follow Go’s acronym capitalization conventions.
	PolicyId              uuid.UUID `json:"policy_id" validate:"required"`

Comment thread internal/verifierapi/fees.go Outdated
Comment on lines +110 to +114
defer func() {
if err := response.Body.Close(); err != nil {
v.logger.WithError(err).Error("Failed to close response body")
}
}()

Copilot AI Jul 4, 2025

Copy link

Choose a reason for hiding this comment

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

The defer response.Body.Close() is placed after JSON decoding, but earlier return paths (e.g., non-OK status or decode error) won't close the body, causing a resource leak. Move the defer immediately after obtaining the response.

Copilot uses AI. Check for mistakes.
Comment thread internal/verifierapi/fees.go
…t logging and ensuring proper response body closure

@garry-sharp garry-sharp 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

@garry-sharp
garry-sharp merged commit 9a9bbb3 into main Jul 4, 2025
3 checks passed
@garry-sharp
garry-sharp deleted the refactor-return-type branch July 4, 2025 10:12
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