theupdateframework / theupdateframework/python-tuf
metadata API: serialization is missing a final newline
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 304
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 17
Description
Our JSON serialization is basically json.dumps(metadata_obj.to_dict(), ...).encode("utf-8")
json.dumps() return value does not end in a newline. This means any files written with this content will not end in a newline: this makes the produced files not valid posix text files.
For Metadata.to_file() this seems like a minor bug (and Metadata.to_bytes() should have the same output for consistency), so in practice JSONSerializer.serialize() probably should add the final newline.
My only concern about this is that it is an unexpected change in the serialization output... IF we change this, we should definitely consider this an API change for users who produce metadata.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at JSONSerializer.serialize(), then inspect Metadata.to_file() and Metadata.to_bytes() to compare their current output. Confirm the expected final-newline behavior and assess the serialization API compatibility impact before deciding what tests or documentation must change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100