Skip to content

Export subcommands accept arbitrary positional args, then perform a Cronometer login #23

Description

@DTTerastar

None of the export subcommands declare a Cobra Args: validator, so any number of extra positional arguments is silently accepted. Combined with #15 (format/flag validation happens after login), this means typos like crono-export bimoetrics --since today (or biometrics today instead of --since today) burn through the Cronometer login rate-limit budget.

Repro on HEAD 0c0e9b664850b334ac9851803f77b08553506af5 (binary at /tmp/qa-bin/crono-export):

$ /tmp/qa-bin/crono-export biometrics extra junk
error: login failed: failed to login: Too Many Attempts. Please try again later.
$ echo $?
1

Expected: extra positional args are rejected locally with a message like error: 'biometrics' takes no positional arguments and exit 1, without any network call.

Source: cmd/biometrics.go, cmd/exercises.go, cmd/nutrition.go, cmd/notes.go, cmd/servings.go — none set Args:.

Fix: add Args: cobra.NoArgs, to each export subcommand's &cobra.Command{...}.

Severity: minor (cosmetic on its own; major when combined with the rate-limit cost from #15).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions