Skip to content

feat(go): add size guardrails for strings, collections and maps#3423

Draft
Zakir032002 wants to merge 5 commits intoapache:mainfrom
Zakir032002:issue-3419-go-guardrails
Draft

feat(go): add size guardrails for strings, collections and maps#3423
Zakir032002 wants to merge 5 commits intoapache:mainfrom
Zakir032002:issue-3419-go-guardrails

Conversation

@Zakir032002
Copy link

@Zakir032002 Zakir032002 commented Feb 25, 2026

Why?

Closes #3419

What does this PR do?

Related issues

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

Add three opt-in guardrail fields to Config and three corresponding
WithXxx option functions. All default to 0 (unlimited), preserving
full backward compatibility. Enforcement in read paths follows in
subsequent commits.
go/fory/fory.go Outdated
MaxDepth int
IsXlang bool
Compatible bool // Schema evolution compatibility mode
MaxStringBytes int
Copy link
Collaborator

Choose a reason for hiding this comment

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

I updated issue, could you simplify to MaxBinarySize and MaxCollectionSize only

Copy link
Author

@Zakir032002 Zakir032002 Feb 28, 2026

Choose a reason for hiding this comment

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

yes, working on it

@Zakir032002 Zakir032002 force-pushed the issue-3419-go-guardrails branch from 8c7fd1d to 3c5f854 Compare March 1, 2026 10:19
@Zakir032002 Zakir032002 force-pushed the issue-3419-go-guardrails branch from 3c5f854 to aa315de Compare March 1, 2026 10:23
The checkBinarySize method in ReadContext was never called from any
deserializer path. Per maintainer guidance, size checks are only needed
at preallocation sites. The MaxBinarySize config field and WithMaxBinarySize
option are retained as reserved API.
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.

[Go] configurable size guardrails for untrusted payloads

2 participants