fix(gitea-sync): unwrap buglog.json's {version,bugs} wrapper before iterating (bug-1677)

sync_bugs() read buglog.json as a bare list and wrote it back the
same way, but the real format is {"version": 1, "bugs": [...]}. Any
real run would have crashed on the first bug entry (enumerate() over
a dict yields its keys, not bug objects) and, had it somehow gotten
past that, a write-back would have destroyed the wrapper. Never
actually run against production Gitea, per the buglog entry.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AgYRU3zDTqNGV5Jk8aiKLg
This commit is contained in:
Rongsong Shen 2026-08-24 14:23:31 +00:00
parent a58c2a19e6
commit 643741fad5
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2

View file

@ -723,7 +723,8 @@ def sync_bugs(api, dry_run=False, quiet=False, since=None):
warn(f"buglog not found: {BUGLOG_PATH}") warn(f"buglog not found: {BUGLOG_PATH}")
return return
buglog = json.loads(BUGLOG_PATH.read_text()) buglog_wrapper = json.loads(BUGLOG_PATH.read_text())
buglog = buglog_wrapper["bugs"]
created = 0 created = 0
closed = 0 closed = 0
skipped = 0 skipped = 0
@ -796,7 +797,8 @@ def sync_bugs(api, dry_run=False, quiet=False, since=None):
# Write back updated buglog if any new issues were created # Write back updated buglog if any new issues were created
if created > 0 and not dry_run: if created > 0 and not dry_run:
_write_json(BUGLOG_PATH, buglog) buglog_wrapper["bugs"] = buglog
_write_json(BUGLOG_PATH, buglog_wrapper)
if not quiet: if not quiet:
print(f"Bugs: {created} created, {closed} closed, {skipped} skipped") print(f"Bugs: {created} created, {closed} closed, {skipped} skipped")