Skip to content

Do not log or persist API credentials; allow endpoint override - #4

Open
KTanmay1 wants to merge 1 commit into
DeepSoftwareAnalytics:mainfrom
KTanmay1:fix/credential-handling
Open

Do not log or persist API credentials; allow endpoint override#4
KTanmay1 wants to merge 1 commit into
DeepSoftwareAnalytics:mainfrom
KTanmay1:fix/credential-handling

Conversation

@KTanmay1

Copy link
Copy Markdown

Problem

RepoTransAgent/generator.py exposes the API key in two places:

  • :93 logs it verbatim on every request: self.logger.info(f"Using key: {self.api_key}")
  • record_conversation writes the live Authorization: Bearer <key> header into conversation_logs/*.json — which is the directory a user would naturally attach to a bug report

The endpoint is also hardcoded, so pointing the agent at a different provider means editing source.

Separately, a blank or malformed API_KEY.txt fails with IndexError from line.split()[1] rather than a message saying what is wrong. That is close to the startup confusion reported in #2.

Changes

  • Log only the last four characters of the key.
  • Redact the Authorization header before writing conversation logs.
  • Read the endpoint from REPOTRANSBENCH_BASE_URL, defaulting to the current value so existing setups are unaffected.
  • Read keys from REPOTRANSBENCH_API_KEY (comma-separated, for the existing rotation behaviour) when set, otherwise from API_KEY.txt exactly as before.
  • Raise a clear error when no key is configured.

Verification

Exercised all three paths locally: env-supplied keys rotate as before, REPOTRANSBENCH_BASE_URL overrides and strips a trailing slash, and an empty API_KEY.txt now reports No API key found. Set REPOTRANSBENCH_API_KEY, or add lines of the form "<name> <key>" to RepoTransAgent/API_KEY.txt.

No change to agent behaviour, prompts, or scoring.

The agent currently writes the API key to stdout on every request and
stores the live `Authorization: Bearer <key>` header in
conversation_logs/*.json, which is the directory users attach to bug
reports. It also hardcodes the API endpoint, so pointing the agent at a
different provider requires editing source.

- Log only the last four characters of the key.
- Redact the Authorization header before writing conversation logs.
- Read the endpoint from REPOTRANSBENCH_BASE_URL, defaulting to the
  current value so existing setups are unaffected.
- Read keys from REPOTRANSBENCH_API_KEY (comma-separated) when set,
  otherwise from API_KEY.txt as before.
- Raise a clear error when no key is configured. A blank or malformed
  API_KEY.txt previously failed with IndexError from line.split()[1].

No change to agent behaviour, prompts, or scoring.
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