Generic API_KEY, BASE_URL and RAG_WORKSPACE env vars are read and reported as "default"

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Start with src/chatty/config.py, especially the Config fields and source tracking around lines 119, 127, and 200. Check how validation_alias and populate_by_name=True affect environment and TOML loading, then run the relevant config tests. Done means TOML values still load by field name, the documented environment aliases still work, and bare API_KEY, BASE_URL, and RAG_WORKSPACE are not read from the environment or reported as defaults.

Written by the indexing model from the issue text.

Description

area: config bug wrong-result

Config reads three fields through validation_alias=AliasChoices(...):

  • base_url: OPENAI_BASE_URL, CHATTY_BASE_URL, base_url (src/chatty/config.py:119)
  • api_key: OPENAI_API_KEY, CHATTY_API_KEY, api_key (line 127)
  • rag_workspace: CHATTY_RAG_WORKSPACE, LITKIT_WORKSPACE, rag_workspace (line 200)

pydantic-settings looks up every alias as an environment variable, case-insensitively, so the TOML key names are also read from the environment as BASE_URL, API_KEY and RAG_WORKSPACE. chatty's source tracking doesn't know about these, so it reports them as default.

Effect: a shell with API_KEY set for some other tool, and no OPENAI_API_KEY, makes chatty send that key as the Bearer token to its endpoint. chatty print-config and chatty doctor then hide where it came from:

  base_url: https://other.example.com/v1 (from: default)
  api_key: ******** (from: default)

RAG_WORKSPACE likewise changes the RAG workspace and is reported as default.

Fix: keep the env aliases in validation_alias and pass TOML values by field name only (populate_by_name=True), or load TOML through a pydantic-settings source, so bare API_KEY, BASE_URL and RAG_WORKSPACE are never read from the environment.

Dominant language
Python
Stars
0
Forks
2
Avg merge
1d 4h
Merged PRs (30d)
13

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 lanl/chatty

All issues in lanl/chatty

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.