fix: include file path in JSON parse errors for INPUT.json - #1339
Open
kuntal1461 wants to merge 1 commit into
Open
fix: include file path in JSON parse errors for INPUT.json#1339kuntal1461 wants to merge 1 commit into
kuntal1461 wants to merge 1 commit into
Conversation
- Wrap JSON.parse in resolveInput() (apify actor call path) with try/catch that includes the full file path - Wrap JSON.parse in getInputOverride() --input-file path with the same fix - Wrap JSON.parse in RunCommand (apify run path) with try/catch + file path - Cast inputJson to Record<string,unknown> after array guard to satisfy TS - Fix incorrect node:path/win32 import in run.test.ts (should be node:path) - Add tests for all three JSON parse error paths
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.
Fixes #1181
What changed
resolveInput()(apify actor call/apify task callpath): bareJSON.parsenow wrapped in try/catch that throws with the full file path in the messagegetInputOverride()--input-filepath (apify run --input-file): same fix — file path included in parse errorRunCommand(apify runwith input schema): same fix — file path included in parse error; also castinputJsontoRecord<string,unknown>after the array guard to fix a TypeScript spread error introduced by theunknownannotationrun.test.ts: fixed incorrectimport { dirname } from 'node:path/win32'→node:path(worked by accident on macOS, semantically wrong)Tests added
resolve-input.test.ts— new test:getInputOverridewith a malformed--input-fileincludes the file path in the errorresolve-input.test.ts— newresolveInputdescribe block: malformedINPUT.jsonin local KV store includes the file pathrun.test.ts— new test:apify runwith a malformedINPUT.jsonincludes the path and the parse detailChecklist
pnpm run lint— 0 warnings, 0 errorspnpm run format— all files correctly formattedpnpm run build— cleanpnpm run test:local— 420/420 non-Python tests pass (2[python]failures are pre-existing env issue: Python 3.14 Homebrewexternally-managed-environment, unrelated to this change)