Skip to content
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

source JSON might be lost in a corner case #35

Open
ldn-softdev opened this issue Apr 15, 2021 · 1 comment
Open

source JSON might be lost in a corner case #35

ldn-softdev opened this issue Apr 15, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@ldn-softdev
Copy link
Owner

ldn-softdev commented Apr 15, 2021

When option -f is used (to update the output right into the source JSON file) and either of these failures occur:

  • fail: template argument failed interpolation
  • fail: file <name> holds an invalid JSON
  • fail: argument walk-type (<walk>) not allowed, due to mode <mode> already set
  • fail: non-walk argument <arg> not allowed, due to option -<opt> given
  • fail: non-walk argument <arg> not allowed, due to mode <mode> already set

then the source JSON file is lost (becomes empty)

@ldn-softdev ldn-softdev added the bug Something isn't working label Apr 15, 2021
@ldn-softdev
Copy link
Owner Author

ldn-softdev commented Apr 15, 2021

Analysis:
When either of the reported failures happen (given option -f), they occur after source JSON file already open for write (and hence already truncated).

One of the feasible solutions: reinstate (rewrite) source JSON into the source file upon those cases. Reinstating of the source JSON is preferable solution (vs delaying opening file for write) for couple reasons:

  1. it's much easier/logical from the code design point of view
  2. some of the failures may occur when output JSON might be partially written and thus may result in an inconsistent output

Will be committing changes soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant