fix: resolve validation and parsing bugs in core utilities - #17538
Open
Prabhdeep1701 wants to merge 1 commit into
Open
fix: resolve validation and parsing bugs in core utilities#17538Prabhdeep1701 wants to merge 1 commit into
Prabhdeep1701 wants to merge 1 commit into
Conversation
Author
|
Hey, this PR fixes 7 bugs found through code review — validation edge cases, an unguarded JSON.parse, and a few code quality issues. Let me know if any changes are needed! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
Fixed 7 bugs across payload core utilities:
addDataAndFileToRequest.ts—JSON.parseon_payloadfield had no try/catch, throwing unhandledSyntaxErroron invalid JSONvalidations.ts— point field validator had swapped lng/lat NaN checks (value[1]checked againstlng,value[0]againstlat)validations.ts— removed deadtypeof lng !== 'number'branch in point validator (always false sinceparseFloatreturnsnumber)validations.ts— upload/relationship error messages appended a numeric index to each invalid value due to swapped.map()parameter namesafterRead/promise.ts—getBlockSelect()called withblock!before theif (block)guard, risking runtime error on undefined blockparseParams/index.ts—key in paramsthrowsTypeErrorwhen params is null/undefined (documented as "current implementation bug" in tests)mergeListSearchAndWhere.ts—else ifandelsebranches inhoistQueryParamsToAndexecuted identical codeWhy?
These are runtime correctness bugs. The swapped lng/lat check causes valid point inputs to be rejected. The unguarded
JSON.parsecrashes the server on malformed multipart payloads. The non-null assertion can throw on documents with unknown block types.How?
_payloadJSON.parse in try/catch matching the pattern used forfields.fileon the next linevalue[0]/value[1]indices to match their correct coordinate variablesgetBlockSelect()inside the existingif (block)guardparseParamsfor null/undefined, updated tests from "throws TypeError" to "returns {}".map()callback to remove misleading index