Skip to content

Add store_organization_secret that keeps the value out of errors - #1

Open
dboles99 wants to merge 1 commit into
mainfrom
store-organization-secret
Open

dboles99 wants to merge 1 commit into
mainfrom
store-organization-secret

Conversation

@dboles99

@dboles99 dboles99 commented Dec 6, 2026

Copy link
Copy Markdown
Owner

Mirror of prooflinedev#172, opened in my fork so Proofline can review it. Same commit; discussion stays on the upstream PR.

Who it helps

Organization admins and CI jobs that store or rotate secrets (org:configure). Today a problem that repeats the value lands in ProoflineError.detail, and a raised error can keep a chained exception or httpx frames that hold the JSON body.

What it does

from pydantic import SecretStr

stored = client.store_organization_secret(org_id, "DEPLOY_KEY", SecretStr(deploy_key))
print(stored.name)
  • New store_organization_secret (both clients) checks the organization ID, the name (an ASCII letter, then up to 63 letters, digits, _ or -) and the value (1 to 32,768 UTF-8 bytes) before any request, and accepts a result only if the server confirms the same name.
  • set_organization_secret and put_organization_secret keep their behavior: same arguments, same request, server-side checks, any 200 accepted, same ProoflineError types. They gain only redacted problem text and detached errors.
  • All three replace the sent value, as sent, JSON-escaped or as a Python repr, with [redacted] in every problem field, including typed configuration problems.
  • All three raise a ProoflineError with no chained exception and no HTTP-layer frames, and send the write once.

Decisions

  • Redaction values live in a context variable for one call, so concurrent tasks or threads on one client each redact their own value. Rejected: an attribute on the client, which a second concurrent write would overwrite.
  • The legacy methods call the generated operation unchanged. For a duck-typed body they redact whatever str to_dict() yields and skip redaction otherwise. Rejected: moving them onto the new checks, which would turn server errors into local ValueErrors for existing callers.
  • One regex pass with the longest form first. Rejected: chained str.replace, which can match inside an earlier [redacted].
  • Errors drop their traceback below the public method. Rejected: keeping it, because a reporter that records locals would read the JSON body from httpx frames. A caller's own str or SecretValue can still show in the caller's frames, so the README says to pass SecretStr.

How verified

.venv\Scripts\python.exe -m pytest -q -p no:cacheprovider --basetemp G:\tmp\proofline-a-pytest-r2
352 passed, 0 failed, 0 errors (before: 237 passed, 1 failed: the known Windows
test_body_stream_deadline_does_not_turn_authority_into_timeout[200-sync], which passed this run)
.venv\Scripts\python.exe -m pytest -q -p no:cacheprovider tests/test_secrets.py   114 passed
.venv\Scripts\python.exe -m ruff check --no-cache .            All checks passed
.venv\Scripts\python.exe -m ruff format --no-cache --check .   319 files already formatted
.venv\Scripts\python.exe -m mypy proofline scripts             no issues in 310 files
.venv\Scripts\python.exe scripts/contracts.py                  passed
.venv\Scripts\python.exe scripts/generate.py --check           passed

The new tests pin the legacy call shape (org_id=, name=, keyword-only body=) and check that invalid legacy input still reaches the server and comes back as ProoflineError. They fail when the redaction, the repr form or the traceback detaching is removed. scripts/check.py was not run because it downloads uv and the pinned packages.

Who: Admins and CI jobs that store or rotate organization secrets.
What: New store_organization_secret with local checks and name
confirmation. set_/put_organization_secret keep their behavior and
only gain redacted problem text and detached errors.
Where: proofline/client.py, proofline/_transport.py, regenerated
operations.py, scripts/contracts.py, README.md, tests/test_secrets.py.
When: On every secret write and every problem it returns.
Why: A problem that echoed the value reached ProoflineError.detail, and
errors kept chains and frames that could hold the request body.
How verified: pytest 352 passed, 0 failed, 0 errors (before: 237
passed, 1 known Windows failure); ruff, mypy, contracts, generate pass.
Copilot AI balanced review requested due to automatic review settings December 6, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants