Skip to content

fix: parse Tempo chain IDs strictly - #94

Open
cryptoryda wants to merge 4 commits into
tempoxyz:mainfrom
cryptoryda:tempo.ParseChargeRequest
Open

fix: parse Tempo chain IDs strictly#94
cryptoryda wants to merge 4 commits into
tempoxyz:mainfrom
cryptoryda:tempo.ParseChargeRequest

Conversation

@cryptoryda

Copy link
Copy Markdown
Contributor

Validate Tempo chainId parsing strictly

Summary

  • reject fractional numeric methodDetails.chainId values
  • reject malformed string chainId values instead of accepting partial parses
  • add regression coverage for both malformed inputs

Why

Charge requests should not silently coerce an invalid chain ID. This keeps challenge parsing deterministic and prevents accidental chain mismatches.

Tests

GOCACHE=/private/tmp/mpp-go-cache go test ./pkg/tempo
GOCACHE=/private/tmp/mpp-go-cache go test ./...

@brendanjryan

Copy link
Copy Markdown
Contributor

Hi! is this meant to be an application change? it only looks like it changes tests

@cryptoryda

Copy link
Copy Markdown
Contributor Author

Yes, this is intended to be an application change. The implementation file was accidentally omitted from the previous commit. I’ve now added the strict chainId validation to pkg/tempo/request.go and kept the related regression tests in pkg/tempo/helpers_test.go. Thanks for catching this

@brendanjryan

Copy link
Copy Markdown
Contributor

can you add tests / coverage for the application changes (func asInt64(value any) (int64, bool, error)) explicitly?

@cryptoryda

Copy link
Copy Markdown
Contributor Author

I’ve added explicit table-driven tests for asInt64, covering int, int64, whole-number floats, valid strings, fractional floats, malformed strings, empty strings, unsupported types, and nil. I’ve also retained the ParseChargeRequest regression tests to verify the application-level behavior.

@brendanjryan

Copy link
Copy Markdown
Contributor

thanks!

@brendanjryan

Copy link
Copy Markdown
Contributor

@codex review

there are some lint issues too @cryptoryda

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7cea033391

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/tempo/helpers_test.go

}

tests := []struct {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Wrap the new table test in a test function

The new tests := ... declaration is at package scope rather than inside a function, so Go cannot parse this test file (expected declaration, found tests). Consequently, every go test invocation that includes pkg/tempo fails before compiling or running any tests; add the missing func TestAsInt64(t *testing.T) { ... } wrapper around the table and loop.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated lint issue

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants