Skip to content

fix(schema): preserve caller-owned JSON parser config - #1485

Open
123XieC wants to merge 1 commit into
cloudwego:mainfrom
123XieC:fix/schema-preserve-json-parser-config
Open

123XieC wants to merge 1 commit into
cloudwego:mainfrom
123XieC:fix/schema-preserve-json-parser-config

Conversation

@123XieC

@123XieC 123XieC commented Nov 12, 2026

Copy link
Copy Markdown

What type of PR is this?

fix

Check the PR title.

  • Uses a conventional commit prefix and scope.
  • Describes the behavior visible to callers.

More detailed description

NewMessageJSONParser now applies the default input source to a local copy of MessageJSONParseConfig. Multiple parser constructors can reuse the same read-only config without racing, and omitting the input source still parses from message content.

The regression parses the configured id key with the default source and verifies that the caller's config remains unchanged. The standalone example in the linked issue reported a read/write race and parse_from = "content" on the base commit. It prints parse_from = "" with no race report after this patch.

  • go test -race ./schema ./compose passed on Go 1.26.9.
  • gofmt and the repository's golangci-lint 2.8.0 (Go 1.25.5) passed.

AI assistance was used to investigate, implement, and test the change.

Which issue(s) this PR fixes

Fixes #1484.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

schema: NewMessageJSONParser mutates shared configuration

1 participant