Skip to content

Comments

debug format-obj: support all repo object types, fixes #9391#9393

Open
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:fix-debug-format-obj-robj-type
Open

debug format-obj: support all repo object types, fixes #9391#9393
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:fix-debug-format-obj-robj-type

Conversation

@mr-raj12
Copy link
Contributor

Description

  • do_debug_format_obj hardcodes ro_type=ROBJ_FILE_STREAM, ignoring the "type" field in the metadata JSON

  • This breaks the debug round-trip (get-obj → parse-obj → [edit] → format-obj → put-obj) for non-file-stream objects (manifest, archive metadata, archive chunkids, archive stream)

    • parse-obj already outputs the "type" field in metadata JSON, and RepoObj.format() is fully generic
    • Fix: extract ro_type from metadata dict, matching the existing pattern in repo_compress_cmd.py:46

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

    Changes

    File Change
    src/borg/archiver/debug_cmd.py Replace hardcoded ROBJ_FILE_STREAM with meta.pop("type", ROBJ_FILE_STREAM)
    src/borg/testsuite/archiver/debug_cmds_test.py Add test_debug_format_obj_respects_type — round-trip test with ROBJ_ARCHIVE_STREAM

    Checklist

    • PR is against master
    • New code has tests
    • Tests pass
    • Commit message references related issue
    • Code formatted with black

@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.44%. Comparing base (0354697) to head (de71daa).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9393   +/-   ##
=======================================
  Coverage   76.43%   76.44%           
=======================================
  Files          85       85           
  Lines       14800    14801    +1     
  Branches     2212     2212           
=======================================
+ Hits        11313    11314    +1     
  Misses       2809     2809           
  Partials      678      678           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

create_regular_file(archiver.input_path, "meta.json", contents=meta)
output = cmd(archiver, "debug", "id-hash", "input/plain.bin")
id_hash = output.strip()
cmd(archiver, "debug", "format-obj", id_hash, "input/plain.bin", "input/meta.json", "output/data.bin")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rather rename for more clarity:
input/plain.bin -> input/data.bin
output/data.bin -> output/repoobj.bin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even better: input/repoobj.bin (it is input for the put-object you do next)

also rename the other places accordingly.

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.

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

2 participants