refactor(cmdutils): share ParseID helper so invalid-ID errors name rejected value

Description

Related to #8691.

This MR introduces a shared ID-parsing helper in internal/cmdutils so that invalid numeric ID arguments produce clear, actionable error messages naming the rejected value.

Problem

Previously, eighteen commands printed a bare strconv error when an ID argument was not a valid number (e.g., strconv.ParseInt: parsing "abc": invalid syntax.). The descriptive string passed to cmdutils.WrapError(err, "invalid runner controller ID") was stored in ExitError.Details, but ExitError.Error() never renders Details, causing the user-facing explanation to be discarded.

Solution

  1. Added cmdutils.ParseID(value, name string) (int64, error):
    • Parses value as a 64-bit integer.
    • Validates id >= 1 (rejecting 0, negative values, floats, and non-numeric strings).
    • Returns a structured error: invalid <name>: "<value>".
    • Comprehensive unit tests added in internal/cmdutils/parse_id_test.go.
  2. Migrated internal/commands/runnercontroller:
    • Updated 12 ID parsing call sites across 10 packages (delete, get, scope/create, scope/delete, scope/list, token/create, token/list, token/revoke, token/rotate, update).
  3. Migrated internal/commands/runner:
    • Updated 6 ID parsing call sites across assign, delete, jobs, managers, unassign, and update.
    • Tightened invalid-ID test assertions across runner and runnercontroller commands to check the full invalid <name>: "<value>" message.
  4. Consolidated container_registry and deploy-token call sites:
    • Removed the redundant internal/commands/container_registry/registryutils.ParseID wrapper and its duplicate test; updated the 5 container_registry callers (repository/delete, repository/view, tag/delete, tag/list, tag/view) to call cmdutils.ParseID directly.
    • Updated internal/commands/deploy-token/get/get.go and internal/commands/deploy-token/delete/delete.go to use cmdutils.ParseID and removed the obsolete workaround comment.

Related to #8691

Edited by AMIR

Merge request reports

Loading
Loading