Skip to content

fix(config): the cache dials localhost when valkey.url is unset #7427

Done

Description

@dan-petty

Problem Description

valkey.url has the default valkey://localhost:6379/0 (DEFAULT_VALKEY_URL in src/devops_cli/config/defaults.py:748, used by ValkeyConfig.url and ValkeyConfig.endpoint in src/devops_cli/config/settings.py). When a configuration file sets no URL, each cache client dials the loopback address. In the devcontainer no Valkey listens there, so each call fails, the circuit breaker opens, and each later call counts one error with the label error="open".

The owner rule of #1165 says that a client never falls back to an unconfigured service URL. This default is a fallback of that kind.

Evidence

Prometheus, 24 hours to 2026-11-27 15:40 UTC, sum by (job,error) (increase(devops_cli_valkey_cache_errors_total[24h])):

  • job="devops-cli", error="open": about 403,000.
  • job="devops-cli", error="connection": about 535.
  • No other series. All of these come from one instance, the devcontainer, through the operations get, hget and set.

The roadmap Jobs and the Service have a configured URL and count no error in the same window. So the local default makes almost all of the series, which hides a real error of a cluster client.

Expected Behavior

With no valkey.url, the shared cache tier is off: the client makes no connection and counts no error, and the command works from its local tier as it does when the circuit is open. A command that needs Valkey (such as devops valkey) fails with an error that names valkey.url. The setting valkey.url has no default value.

Acceptance Criteria

  • With valkey.url unset, a cache read and a cache write make no connection and add nothing to devops_cli_valkey_cache_errors_total.
  • With valkey.url unset, devops valkey fails with an error that names valkey.url.
  • DEFAULT_VALKEY_URL is gone, and the generated configuration documents show no default for valkey.url.

Related

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches surfaced only general-purpose cache libraries (cashews, aiocache, diskcache) and unrelated docs; none removes a project's own default service URL, so the fix stays in this repo's settings and metrics.

Lacks:

  • No library deletes a project's own DEFAULT_VALKEY_URL constant
  • No optional remote tier that stays off when the URL is unset
  • No guard that stops cache error counters while unconfigured
  • No config schema that documents valkey.url without a default

Proposed design

Problem statement

The Valkey settings fall back to valkey://localhost:6379/0 when valkey.url is unset. In the devcontainer no Valkey listens there, so each cache call fails, the circuit opens, and devops_cli_valkey_cache_errors_total counts about 403,000 error="open" events in 24 hours. This hides real cluster errors. The change removes the default, keeps the remote cache tier off when the URL is unset, and makes devops valkey fail with an error that names valkey.url.

Acceptance criteria

Requirement: Unset URL disables the remote cache tier

When valkey.url is unset, the cache client MUST make no remote connection and MUST not increment devops_cli_valkey_cache_errors_total.

Scenario: Read and write with no URL

  • WHEN a test builds the cache client with valkey.url unset and calls get and set
  • THEN the client makes no remote connection and the error counter value stays the same

Requirement: Unset URL keeps the local cache tier

When valkey.url is unset, the cache MUST serve reads and writes from its local tier.

Scenario: Local round trip with no URL

  • WHEN a test writes a value and reads it back through the cache with valkey.url unset
  • THEN both calls succeed from the local tier and no remote call is made

Requirement: devops valkey requires a URL

The devops valkey command MUST fail with an error that names valkey.url when the setting is unset.

Scenario: Valkey command with no URL

  • WHEN a test invokes devops valkey with valkey.url unset
  • THEN the command exits non-zero and its error text contains valkey.url

Requirement: The endpoint accessor refuses an unset URL

ValkeyConfig.endpoint MUST raise ConfigurationError naming valkey.url when the URL is unset or empty.

Scenario: Endpoint with no URL

  • WHEN a test reads endpoint from ValkeyConfig() with no valkey.url
  • THEN the call raises ConfigurationError and the message contains valkey.url

Requirement: The default Valkey URL constant is removed

The configuration package MUST NOT define DEFAULT_VALKEY_URL.

Scenario: Default constant is absent

  • WHEN a test imports devops_cli.config.defaults
  • THEN the module has no attribute DEFAULT_VALKEY_URL

Requirement: Valkey URL defaults to unset

ValkeyConfig.url MUST default to None.

Scenario: Settings with no URL

  • WHEN a test builds ValkeyConfig() with no valkey.url
  • THEN the url field is None and the model field default is None

Requirement: Configuration reference shows no Valkey default

The generated configuration reference MUST show valkey.url without a default value.

Scenario: Configuration reference rendering

  • WHEN a test renders the configuration reference for ValkeyConfig
  • THEN the valkey.url entry has no default value

Existing Tool Considered

The alternatives check in the issue body has verdict none and names no tool. It considered cashews, aiocache and diskcache, and none covers the need. The change is a small in-repo edit: remove DEFAULT_VALKEY_URL, default valkey.url to None, and skip the remote cache tier when it is unset. Cost: about 2,000 to 4,000 tokens to write, keep and fix, and less than one hour of elapsed work. It adds no dependency.

Key questions

  • What should ValkeyConfig.url do when no configuration file sets a URL?: It should default to None. The endpoint property should raise ConfigurationError naming valkey.url when the value is unset or empty. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/defaults.py:748]
  • How should the cache client act when valkey.url is unset?: It should skip the remote tier, serve reads and writes from the local tier, open no connection and add no cache error sample. (best practice) [sources: src/devops_cli/valkey/cache.py, src/devops_cli/telemetry/instruments.py, src/devops_cli/valkey/client.py]
    • Rejected: Dial valkey://localhost:6379/0. No Valkey listens in the devcontainer. Each call fails, the circuit opens and the error counter hides real errors.
    • Rejected: Fail each cache operation. Commands should work from the local tier as they do when the circuit is open.
    • Chosen: Skip the remote tier and use the local tier. It meets the expected behavior and stops the false error="open" series.
  • Where should the error for an unset valkey.url come from?: ValkeyConfig.endpoint is the shared accessor that parses the URL. It already takes the setting name valkey.url for its error. [sources: src/devops_cli/config/settings.py]
  • Which component increments devops_cli_valkey_cache_errors_total?: The counter is defined in src/devops_cli/telemetry/instruments.py. The Valkey cache client and the shared listing store increment it. [sources: src/devops_cli/telemetry/instruments.py, src/devops_cli/valkey/cache.py, src/devops_cli/roadmap/stores/listing_shared.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/config
    source/agent
    status/new
    on Nov 27, 2026
  2. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor
  3. added
    value/medium
    effort/low
    priority/p1-high
    on Nov 27, 2026
  4. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (7)

    Tools considered:

    Searches run:

    • python cache library optional redis backend no default endpoint falls back to in-memory, results: 5
    • redis-py client connect only when url configured disable shared cache tier, results: 5
    • cashews python cache redis memory backend optional configuration, results: 5
    • pydantic settings optional field no default redis url, results: 5
    • cashews cache pypi, results: 5
    • aiocache multiple backends memory redis configure, results: 5
    • circuit breaker redis client no connection when endpoint unset python, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Nov 27, 2026
  6. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  9. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-28 06:56 UTC

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

    effort/lowpriority/p1-highscope/configsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions