conductor-oss/conductor · error · IllegalArgumentException
token must not be blank
Error message
token must not be blank
What it means
Thrown by the StaticTokenProvider constructor when the token argument is null or blank (String.isBlank). StaticTokenProvider wraps non-expiring API keys (OpenAI, Anthropic, etc.), and a blank key is treated as a programming/config error rather than a recoverable runtime condition. It is an IllegalArgumentException, so it surfaces immediately at bean/wiring time, not at first use.
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/agent/credentials/StaticTokenProvider.java:22
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.conductoross.conductor.ai.agent.credentials;
/** {@link TokenProvider} for non-expiring API keys (OpenAI, Anthropic, etc.). */
public class StaticTokenProvider implements TokenProvider {
private final String token;
public StaticTokenProvider(String token) {
if (token == null || token.isBlank()) {
throw new IllegalArgumentException("token must not be blank");
}
this.token = token;
}
@Override
public String getToken() {
return token;
}
}
View on GitHub (pinned to cf7c3e4a8a)
Solutions
- Set the missing API-key environment variable / property to a real, non-blank value.
- Verify the property/env name the StaticTokenProvider is built from exactly matches what is configured (typo in @Value("${...}") is common).
- Add a startup health check or @PostConstruct assertion that fails fast with a clear message when the key source is empty.
- If the key genuinely can be absent in some profile, build a different TokenProvider (or skip the AI integration) conditionally instead of constructing StaticTokenProvider with null.
Example fix
// before
new StaticTokenProvider(System.getenv("OPENAI_KEY")) // null if unset
// after
String key = System.getenv("OPENAI_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("OPENAI_KEY env var is not set");
}
new StaticTokenProvider(key); Defensive patterns
Strategy: validation
Validate before calling
String key = System.getenv("OPENAI_API_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("OPENAI_API_KEY is not set; cannot build StaticTokenProvider");
}
new StaticTokenProvider(key); Try / catch
try {
return new StaticTokenProvider(key);
} catch (IllegalArgumentException e) {
// fail fast at startup with a clear message rather than at first request
throw new IllegalStateException("Missing API key: " + e.getMessage(), e);
} Prevention
- Set required API-key env vars in every deployment profile and verify in a startup check.
- Use Spring @Value with a clear error or a @ConfigurationProperties validator so a missing key fails the context refresh loudly.
- Keep secret rotation tooling that never writes an empty value.
When it happens
Trigger: Constructing new StaticTokenProvider(token) where token came from an environment variable or config property that is unset or empty. Typically fails during Spring bean creation at startup.
Common situations: The API key env var (e.g. OPENAI_API_KEY) is not set in the deployment; the property name in YAML does not match what the code reads; a secret manager rotation left the value temporarily empty; a placeholder like ${API_KEY} was left unresolvable.
Related errors
- Connection factory is undefined
- Addresses are undefined
- Settings are undefined
- Batch size must be greater than 0
- Poll time must be greater than 0 ms
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/3a3dad7d07a6d5a2.
Report an issue: GitHub.