Skip to content

fix(credentials): surface host-list query failures instead of returning an empty success #48

Closed

Description

@spelech

Finding

GET /admin/api/settings/hosts returns HTTP 200 with [] when the backing credential query fails. Users cannot distinguish "no configured Git hosts" from "credential metadata could not be read."

Related reproducer: #45. This issue covers error propagation/observability rather than duplicating the full database-compatibility migration.

Observed evidence

At source revision 41ec093a745f1c0277893dc8f758b96b216c970f, a fresh full-PostgreSQL deployment with authentication enabled initialized its PostgreSQL schema and admin key. An authenticated host-list request returned:

GET /admin/api/settings/hosts -> HTTP 200
[]

The application logged:

Failed to list git host credentials: no such table: git_host_credentials

Root cause:

Expected outcome

  • Propagate or explicitly represent credential-store query failures so the API returns a visible non-success error.
  • Reserve HTTP 200 with [] for a successful query with no rows.
  • Preserve existing credential masking and avoid exposing tokens, connection strings, or private host information in errors.

Acceptance checks

  • A successfully queried empty credential store returns HTTP 200 with [].
  • Missing-table, unavailable-database, and query-failure cases produce a sanitized error response, not an empty success.
  • A successful non-empty response retains existing credential masking.

Activity

  1. spelech commented on Oct 27, 2026

    @spelech
    OwnerAuthor

    Triage & Implementation Brief

    1. Scope & Effort

    • Effort: Small (~15 lines of code + unit test)
    • Component: Credentials Service / Settings API

    2. Root Cause & Context

    In app/services/database/credentials.py::list_git_host_credentials(), any database query failure is caught with except Exception: return []. The API endpoint in app/api/routers/settings.py receives an empty list and returns HTTP 200, making database errors indistinguishable from having zero configured credentials.

    3. Implementation Plan

    • Remove the silent except Exception: return [] block in list_git_host_credentials().
    • Propagate database exceptions (or return an explicit error result) to app/api/routers/settings.py.
    • Update settings.py to catch query exceptions and return HTTP 500 with sanitized diagnostics (ensuring tokens or connection strings are never leaked).
    • Reserve HTTP 200 with [] strictly for successful queries that find zero rows.

    4. Acceptance Criteria

    • Successfully querying an empty credential table returns HTTP 200 with [].
    • Missing tables or database connection failures return HTTP 500 with sanitized error details.
    • Existing credential token masking is preserved.
  2. google-labs-jules commented on Oct 27, 2026

    @google-labs-jules
    Contributor

    Jules is on it. When finished, you will see another comment and be able to review a PR.

  3. google-labs-jules commented on Oct 27, 2026

    @google-labs-jules
    Contributor

    Ready for a review! A PR has been created.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    julesgoogle-jules-bot

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions