Skip to content

Shadowed error in cmd/history/log.go silently swallows query failures #144

Description

@DylanDevelops

The problem

In cmd/history/log.go under the logDate branch, the err variable is shadowed. When parsedDate, err := parseDateFlag(logDate) is called, a new err is declared inside the block. The subsequent query entries, err = db.GetEntriesByDateRange(start, end) assigns to this inner variable. The outer err (which is nil from storage.Initialize) is checked at the end of the block, meaning a failed date-range query produces an empty "No time entries found" message instead of returning the actual error.

Release version

0.8.6

Operating system

macOS

Steps to reproduce the behavior

  1. Run a tmpo log --date command that forces a database error.
  2. Observe that the command exits gracefully with "No time entries found" instead of propagating the database error to the CLI output.

Screenshots

No response

Additional context

To fix this, declare parsedDate before the assignment or restructure the if-else chain to prevent shadowing the outer err variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: awaiting triageWaiting for an issue to be addressed.type: bugAn issue that contains a bug report.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions