Skip to content

Conversation

@RodrigoVillar
Copy link
Contributor

Why this should be merged

Normally, x = UnmarshalText(MarshalText(x)). However, this currently fails because UnmarshalText() expects a quoted string (as it calls UnmarshalJSON() and JSON marshaling uses quoted strings) while MarshalText() returns a string without quotes.

How this works

Factors out the common logic of UnmarshalText() and UnmarshalJSON() into unmarshalText() (which expects an unquoted string). UnmarshalJSON() now handles its own quoted string logic.

How this was tested

Added a regression test.

Need to be documented in RELEASES.md?

No.

@RodrigoVillar RodrigoVillar self-assigned this Oct 14, 2025
@RodrigoVillar RodrigoVillar added the bug Something isn't working label Oct 14, 2025
@RodrigoVillar RodrigoVillar marked this pull request as ready for review October 14, 2025 20:33
Copilot AI review requested due to automatic review settings October 14, 2025 20:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the secp256k1 private key unmarshaling logic where UnmarshalText was incorrectly delegating to UnmarshalJSON, causing failures when round-trip marshaling text representations since MarshalText returns unquoted strings while UnmarshalJSON expects quoted strings.

  • Refactored unmarshaling logic by extracting common functionality into a new unmarshalText helper method
  • Fixed UnmarshalText to properly handle unquoted text input instead of delegating to JSON unmarshaling
  • Added regression test to verify round-trip text marshaling works correctly

Reviewed Changes

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

File Description
utils/crypto/secp256k1/secp256k1.go Refactored unmarshaling logic to fix text unmarshaling bug and extract common functionality
utils/crypto/secp256k1/secp256k1_test.go Added regression test for text marshaling round-trip functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@joshua-kim joshua-kim moved this to In Progress 🏗️ in avalanchego Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: In Progress 🏗️

Development

Successfully merging this pull request may close these issues.

4 participants