theupdateframework / theupdateframework/python-tuf

metadata API: serialization is missing a final newline

Open
#2,393 2 comments 2 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.