Skip to content

Fix: Add validation for parsed JSON in ImportFormModal#34

Open
prjanitor wants to merge 1 commit intoKryptXBSA:devfrom
prjanitor:prjanitor/e47f872656fb56af4b00720c5b5cad92bdf0ce04
Open

Fix: Add validation for parsed JSON in ImportFormModal#34
prjanitor wants to merge 1 commit intoKryptXBSA:devfrom
prjanitor:prjanitor/e47f872656fb56af4b00720c5b5cad92bdf0ce04

Conversation

@prjanitor
Copy link
Copy Markdown

Summary

Fixed a bug in ImportFormModal.tsx where the code parsed JSON from user input without checking if the result is an array. If a user imports a JSON file containing null, a string, or an object (not an array), accessing forms.length would throw a TypeError.

Changes

  • Added Array.isArray() check after parsing JSON
  • Shows user-friendly error toast if the JSON is not an array
  • Prevents runtime errors from invalid JSON formats

Testing

Test with the following JSON inputs:

  • Valid: [{}] (array) - should import successfully
  • Invalid: null - should show error toast
  • Invalid: {} - should show error toast
  • Invalid: "string" - should show error toast

This PR was generated by PRJanitor — an automated tool that finds and fixes small bugs in open-source projects.

We respect your contribution guidelines — if your project doesn't accept bot PRs, we won't send more. You can also add a .github/prjanitor.yml file with enabled: false to opt out explicitly.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 4, 2026

⚠️ No Changeset found

Latest commit: e9c119e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant