Skip to content

Dead JSON-only retention branch in _create_context() can never execute #177

Description

@codeforester

Summary

The retention-selection logic in _create_context() has an unreachable branch intended to apply a narrower retention policy for JSON-only apps.

Details

  • lib/python/base_cli/app.py:489-503 (App.__init__) only sets self.retention = None in the else branch that requires max_log_files is not None.
  • Consequently, whenever self.retention is None is true at app.py:1224, self.max_log_files is not None is also guaranteed true, so the elif self.max_log_files is not None: branch (:1231) always fires first.
  • The elif context.json_output: branch at :1248 (applying RetentionPolicy(max_bundles=_JSON_DEFAULT_MAX_LOG_FILES) for JSON-only apps with no other retention config) can never execute.

Impact

It happens to be harmless today only because RetentionPolicy.safe_defaults() (the default retention whenever this branch would otherwise matter) coincidentally also uses max_bundles=20, but the intended narrower JSON-only policy (bundle count only, no age/size bound) never actually applies as documented in docs/json-contracts.md ("JSON mode bounds default-log retention to the most recent 20 run bundles"). A future change to either default would silently diverge from the documented contract without any test catching it, since the branch is currently dead.

Suggested fix

Remove the dead branch, or restructure App.__init__/_create_context so context.json_output-driven retention is reachable when intended.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Backlog

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions