validateAuthHeaderDialect function

void validateAuthHeaderDialect(
  1. String? authHeader,
  2. ProviderSpec? spec,
  3. String where
)

Rejects a config-declared authHeader on a provider whose adapter does not read the field (issue #964 review): only the OpenAI-completions adapter family honors it — everywhere else the header would be silently ignored. A null spec (provider unknown at parse time — roles chain entries skip unknown providers at resolve) passes; nothing reaches a builder for it.

Implementation

void validateAuthHeaderDialect(
  String? authHeader,
  ProviderSpec? spec,
  String where,
) {
  if (authHeader == null ||
      spec == null ||
      _authHeaderAdapterKinds.contains(spec.kind)) {
    return;
  }
  throw ConfigException(
    '$where: authHeader only applies to the OpenAI-completions adapter '
    '(openai-completions, minimax, zai, aiin) — provider "${spec.name}" '
    'routes to the ${spec.kind} adapter, which ignores it',
  );
}