[Bug]: TypeScript masking re-resolves already exported secret getters

Open Beginner friendly
#5,708 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Read clients/typescript/src/conversation/secret-registry.ts, especially the maskSecretsInOutput() loop and its cached-key guard. Use the existing TypeScript registry test harness to cover repeated masking of an exported getter, explicit export refresh, and uncached callable resolution. Done means cached getters are not called during masking, while the stated masking and refresh behavior remains covered.

Written by the indexing model from the issue text.

Description

priority:low
Correction after triage

The original rotation report described the Python SDK's deliberate last-resolved-value masking contract. I am retaining that behavior and narrowing this report to an unnecessary getter call in the TypeScript mirror. No cross-SDK rotation-policy change is proposed.

Problem

At 4cc058275c5a08d845bd846576aafc80e5dd7d0d, maskSecretsInOutput() calls source.getValue() before checking !this.exportedValues.has(key). An already exported callable is therefore invoked on every masking call, although its new value is discarded and the cached exported value is used.

The TypeScript loop and Python cache guard differ here. Python skips a cached source before resolving it. LocalConversation.maskSecrets() directly delegates to the TypeScript method.

Reproduction

Using the existing TypeScript registry test harness:

const registry = new SecretRegistry();
let calls = 0;
registry.updateSecrets({ TOKEN: () => { calls++; return 'cached-token'; } });
registry.getSecretsAsEnvVars('$TOKEN');
registry.maskSecretsInOutput('cached-token');
registry.maskSecretsInOutput('cached-token');
expect(calls).toBe(1);

The identical regression test fails on the unchanged base with expected 3 to be 1; the other 24 focused cases pass. Moving the existing cached-key guard before getValue() makes all 25 focused cases pass. The test also checks that an explicit subsequent export resolves the getter again, refreshes the cache, and still masks the newly exported value. A separate case preserves uncached callable resolution. No model or remote service was called.

Intended scope

Skip resolution only for keys that already have an exported cached value. Preserve current masking results, explicit export refresh, uncached resolution, failure handling and replacement order. This is not a claim of full Python parity: TypeScript's uncached-success caching and retry backoff remain separate concerns.

I will wait for readiness triage before opening a PR. The previous rotation proposal is retained locally as research and will not be submitted.

Analysis, regression and proposed fix were prepared with assistance from OpenAI Codex.

Dominant language
Python
Stars
1.4k
Forks
797
Avg merge
1d 17h
Merged PRs (30d)
354

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenHands/software-agent-sdk

All issues in OpenHands/software-agent-sdk

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.