Adalennis opened a new issue, #9385:
URL: https://github.com/apache/hop/issues/9385
### Apache Hop version?
2.20.0
### Java version?
Java 21
### Operating system
macOS
### What happened?
Reproduced on 2.20.0; the code involved is unchanged on main.
`LanguageModelChatMeta` fills the key fields of the providers with the names
of environment variables, written as plain text: `openAiApiKey =
"OPENAI_API_KEY"`, `huggingFaceAccessToken = "HF_ACCESS_TOKEN"`, `mistralApiKey
= "MISTRAL_API_KEY"` and `anthropicApiKey = "ANTHROPIC_API_KEY"`.
1. The name is sent as the key. `LanguageModelFacade` resolves the field
(`"OPENAI_API_KEY"` resolves to itself), and only calls `getenv(<field value>)`
when the result is blank. With the default value, the key sent is the text
`OPENAI_API_KEY`. With an empty field, it calls `getenv("")`, which is always
null, so no key is sent. The environment variable is used in neither case.
Checked with the samples'
`transforms/languagemodelchat/zero-shot/openai.hpl` pointed at a local
OpenAI-compatible endpoint that logs the request headers, with
`OPENAI_API_KEY=sk-from-env` set in the environment:
- `openAiApiKey` left at its default: `Authorization: Bearer
OPENAI_API_KEY`
- `openAiApiKey` empty: no `Authorization` header
2. Every LLM sample fails `hop lint`. A sample only stores the key of the
provider it uses, so the other fields load with their default values, and lint
rule SEC-002 reports them as hardcoded secrets:
| Sample | SEC-002 errors |
|---|---|
| `languagemodelchat/zero-shot/` openai, mistral, anthropic, huggingface
| 3 each |
| `languagemodelchat/zero-shot/ollama.hpl` | 4 |
| `languagemodelchat/fact-checking/bespoke-minicheck.hpl` | 10 |
| `graphrag-ask.hpl`, `graphrag-ask-hybrid.hpl` | 4 each |
`hop lint` exits 1 on each of them. (#8420 was a different SEC-002 case.)
A possible fix: default the fields to empty, or to `${OPENAI_API_KEY}` and
so on, which the transform page already describes ("stored as it stands so it
can be resolved at run time"). Then either remove the `getenv` fallback, or
make it read a fixed environment variable per provider when the field is empty.
### Issue Priority
Priority: 3
### Issue Component
Component: Transforms
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]