Skip to content

borg debug format-obj hardcodes ROBJ_FILE_STREAM, should support all repo object types #9391

@mr-raj12

Description

@mr-raj12

Summary

  • do_debug_format_obj in src/borg/archiver/debug_cmd.py:268 hardcodes the repo object type to ROBJ_FILE_STREAM
  • The TODO at line 268: # TODO: support misc repo object types other than ROBJ_FILE_STREAM
  • This breaks the debug round-trip (get-obj → parse-obj → [edit] → format-obj → put-obj) for non-file-stream objects
  • borg debug parse-obj already handles all object types (uses ROBJ_DONTCARE) and outputs the "type" field in the metadata JSON
  • RepoObj.format() is fully generic and accepts any ro_type

Current state

Debug command Object type support
debug parse-obj All types (ROBJ_DONTCARE)
debug format-obj ROBJ_FILE_STREAM only (hardcoded)
debug get-obj / debug put-obj Raw bytes (no type handling)

All 6 repo object types exist (constants.py): ROBJ_MANIFEST, ROBJ_ARCHIVE_META, ROBJ_ARCHIVE_CHUNKIDS, ROBJ_ARCHIVE_STREAM, ROBJ_FILE_STREAM,
ROBJ_DONTCARE.

Proposed fix

Extract ro_type from the metadata dict, matching the pattern already used in repo_compress_cmd.py:46:

ro_type = meta.pop("type", ROBJ_FILE_STREAM)
data_encrypted = repo_objs.format(id=id, meta=meta, data=data, ro_type=ro_type)

┌────────────────────────────────┬───────────────────────────────────────────────────────────────────────────┐
│              FileChange                                   │
├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤
│ src/borg/archiver/debug_cmd.pyExtract ro_type from metadata JSON instead of hardcoding ROBJ_FILE_STREAM │
└────────────────────────────────┴───────────────────────────────────────────────────────────────────────────┘

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions