Skip to content

bug: preserve false debug and cache refresh overrides - #444

Open
ningyixi wants to merge 1 commit into
Portkey-AI:mainfrom
ningyixi:fix/false-copy-flags
Open

ningyixi wants to merge 1 commit into
Portkey-AI:mainfrom
ningyixi:fix/false-copy-flags

Conversation

@ningyixi

Copy link
Copy Markdown

Title: Preserve false debug and cache-refresh overrides when copying clients

Description:

  • Honor explicit False values for debug and cache_force_refresh in both Portkey.copy() and AsyncPortkey.copy(), including the with_options aliases. None still inherits the existing value.
  • Add offline request-level tests covering false overrides, inheritance, enabling flags, and the original client's unchanged headers.

Motivation:
Portkey(cache_force_refresh=True).with_options(cache_force_refresh=False) currently still sends x-portkey-cache-force-refresh: true, so a caller cannot disable forced refresh for a request. Debug overrides have the same issue. The or expressions discard False; selecting the existing value only for None preserves the override.

Related Issues:
No existing issue found for these boolean overrides. This does not change HTTP-client defaults or the timeout work in #358/#403.

Verification:

  • pytest tests/test_client_copy.py -q: four request-header regressions fail on the unchanged base; all 16 cases pass with the fix, on Python 3.12.
  • make format and make lint: passed, including mypy (144 source files), Black (171 files), and Ruff.
  • git diff --check: passed.

Tests exercise public chat-completion requests through HTTPX MockTransport. No provider calls, API credentials, or live integration tests were used. AI assistance: OpenAI Codex implementation and validation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant