Skip to content

fix: an unparsable config file no longer deletes the database entry on import - #239

Open
PaulRichez wants to merge 2 commits into
pluginpal:masterfrom
PaulRichez:fix/unparsable-config-file
Open

PaulRichez wants to merge 2 commits into
pluginpal:masterfrom
PaulRichez:fix/unparsable-config-file

Conversation

@PaulRichez

Copy link
Copy Markdown

What does it do?

readConfigFile returns null only when the file doesn't exist (ENOENT). When the file exists but isn't valid JSON, it throws an error naming the file.

  • The diff leaves that file out, with a warning saying why (instead of "An empty config file").
  • The import of that config fails with the error, instead of deleting the config from the database.

Why is it needed?

A merge conflict left in a sync file deleted the config (here the Public role) on import. See #238.

How to test it?

The new integration test Import (unparsable file) breaks user-role.public.json, imports it, checks the error, puts the file back and checks the diff is empty (the role is still in the database). It fails without the fix.

Lint and integration tests pass locally (Node 22, playground on Strapi 5.37).

Related issue(s)/PR(s)

Fixes #238

This branch has not been deployed

No deployments
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.

Importing a config file that isn't valid JSON deletes the config from the database

1 participant