-
Notifications
You must be signed in to change notification settings - Fork 13.6k
chore: MESSAGE_MAX_PARSE_LENGTH environment variable
#40306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dionisio-bot
merged 13 commits into
develop
from
fix/message-parser-max-length-prevention
May 19, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
16a66a4
use environment variable instead of setting for message parsing limit
nazabucciarelli 3ea86ca
add constant use for default value
nazabucciarelli 1525fe3
update tests
nazabucciarelli 7577b2e
delete changeset
nazabucciarelli 2624a17
change env var default value to zero
nazabucciarelli c09c5f5
add test case for 0 value
nazabucciarelli 658fdd6
change meta name
nazabucciarelli d8cd5e7
remove .only
nazabucciarelli 237f52d
remove unneeded test case
nazabucciarelli 270119e
add more robustness when handling raw environment variable
nazabucciarelli 496020d
extract env variable gathering logic to lib
nazabucciarelli 4366e76
remove intermediate var
nazabucciarelli 2c048f4
remove .only
nazabucciarelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { MESSAGE_MAX_PARSE_LENGTH_DEFAULT } from './constants'; | ||
|
|
||
| export function getMessageMaxParseLength(): number { | ||
| const parsed = Number.parseInt(process.env.MESSAGE_MAX_PARSE_LENGTH ?? '', 10); | ||
| return Number.isFinite(parsed) ? parsed : MESSAGE_MAX_PARSE_LENGTH_DEFAULT; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
apps/meteor/tests/unit/lib/getMessageMaxParseLength.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { expect } from 'chai'; | ||
|
|
||
| import { getMessageMaxParseLength } from '../../../lib/getMessageMaxParseLength'; | ||
|
|
||
| describe('getMessageMaxParseLength', () => { | ||
| afterEach(() => { | ||
| delete process.env.MESSAGE_MAX_PARSE_LENGTH; | ||
| }); | ||
|
|
||
| it('should return 0 (default) when env var is not set', () => { | ||
| delete process.env.MESSAGE_MAX_PARSE_LENGTH; | ||
| expect(getMessageMaxParseLength()).to.equal(0); | ||
| }); | ||
|
|
||
| it('should return 0 (default) when env var is empty string', () => { | ||
| process.env.MESSAGE_MAX_PARSE_LENGTH = ''; | ||
| expect(getMessageMaxParseLength()).to.equal(0); | ||
| }); | ||
|
|
||
| it('should return 0 (default) when env var is not a number', () => { | ||
| process.env.MESSAGE_MAX_PARSE_LENGTH = 'abc'; | ||
| expect(getMessageMaxParseLength()).to.equal(0); | ||
| }); | ||
|
|
||
| it('should return the parsed number when env var is a valid integer', () => { | ||
| process.env.MESSAGE_MAX_PARSE_LENGTH = '5000'; | ||
| expect(getMessageMaxParseLength()).to.equal(5000); | ||
| }); | ||
|
|
||
| it('should return 0 when env var is "0"', () => { | ||
| process.env.MESSAGE_MAX_PARSE_LENGTH = '0'; | ||
| expect(getMessageMaxParseLength()).to.equal(0); | ||
| }); | ||
|
|
||
| it('should return 0 (default) when env var is Infinity', () => { | ||
| process.env.MESSAGE_MAX_PARSE_LENGTH = 'Infinity'; | ||
| expect(getMessageMaxParseLength()).to.equal(0); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.