--generate-history reports success but writes nothing when --output is given
Problem
--generate-history --output history.json prints a success message and writes no file. The data is fetched, the summary is printed, and it is then discarded.
The branch at sync.py:10622 has no local-write path:
if args.generate_history:
print(f"\nš Generating history.json (up to 3 years)...")
history = sync.generate_history()
...
print(f"\nā
history.json generated") # <-- claims success
...
# Also publish to GitHub if credentials available
if github_token and github_repo and not args.output:
...publish_to_github...
return # <-- nothing written locally
The only persistence is publish_to_github, guarded by not args.output. So:
| Invocation | Result |
|---|---|
--generate-history (GitHub configured) |
Pushed to GitHub ā |
--generate-history --output history.json |
Nothing written, success reported ā |
--generate-history (local setup, no GitHub) |
Nothing written, success reported ā |
Local-path athletes have no working invocation of this flag, which is the documented way to force a history refresh.
By contrast the automatic path at sync.py:10647 does write locally:
if args.output:
history_path = sync.data_dir / sync.HISTORY_FILE
with open(history_path, 'w') as f:
json.dump(history, f, indent=2, default=str)
Impact
should_generate_history() (sync.py:7479) only regenerates when the file is missing, when the script hash changes, or when it is >28 days old and it is Sunday/Monday between 00:00ā00:15 UTC. Outside that window --generate-history is the intended escape hatch ā and on a local setup it silently does nothing.
Current workaround is to delete history.json so the auto-generation path takes over.
Fix
Mirror the auto path ā write locally when --output is given, before the GitHub branch:
if args.output:
history_path = sync.data_dir / sync.HISTORY_FILE
with open(history_path, 'w') as f:
json.dump(history, f, indent=2, default=str)
print(f" ā
history.json saved to {history_path}")
elif github_token and github_repo:
...
Verified against v3.122.
Another Claude generated PR, again adequate quality.
This does not reproduce. --generate-history writes history.json on every invocation, including with --output.
The write is inside generate_history() itself, before it returns:
# Save locally
history_path = self.data_dir / self.HISTORY_FILE
with open(history_path, 'w') as f:
json.dump(history, f, indent=2, default=str)
print(f" ā
history.json saved ({len(daily_90d)} daily, {len(weekly_180d)} weekly rows)")
sync.py:7518-7522 on main (v3.124), sync.py:7690-7694 on the v3.122 revision you referenced. The if args.generate_history: branch you quoted runs after that call returns, so the file is already on disk when it reports success. --output gates only the GitHub push, hence not args.output. All three rows of your table write the file, and the proposed patch would add a second write of the same data, which is what the automatic path already does.
What you likely hit is where the file lands. data_dir is Path.cwd(), and --output is a path only for latest.json. For history.json, intervals.json, routes.json and ftp_history.json it is a mode selector and its value is ignored, so they go to the working directory, not beside --output. The success message not printing a path makes that hard to spot, which is fair criticism even though nothing was lost.
Closing as not reproducible. If history.json appeared nowhere on your filesystem, reopen with the console output and the directory you ran from.