grpc/grpc-java · error · IllegalArgumentException

No ALTS context information found

Error message

No ALTS context information found

What it means

AltsContextUtil.createFrom() extracts an ALTS peer context from the call Attributes map. The Attributes must contain AltsProtocolNegotiator.AUTH_CONTEXT_KEY holding an AltsInternalContext; when the attribute is absent or holds a different type, no ALTS handshake information is available and the method throws IllegalArgumentException.

Source

Thrown at alts/src/main/java/io/grpc/alts/AltsContextUtil.java:64

   * @param call the {@link ClientCall} containing the ALTS information
   * @return the created {@link AltsContext}
   * @throws IllegalArgumentException if the {@link ClientCall} has no ALTS information.
   */
  public static AltsContext createFrom(ClientCall<?, ?> call) {
    return createFrom(call.getAttributes());
  }

  /**
   * Creates an {@link AltsContext} from ALTS context information in the {@link Attributes}.
   *
   * @param attributes the {@link Attributes} containing the ALTS information
   * @return the created {@link AltsContext}
   * @throws IllegalArgumentException if the {@link Attributes} has no ALTS information.
   */
  public static AltsContext createFrom(Attributes attributes) {
    Object authContext = attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY);
    if (!(authContext instanceof AltsInternalContext)) {
      throw new IllegalArgumentException("No ALTS context information found");
    }
    return new AltsContext((AltsInternalContext) authContext);
  }

  /**
   * Checks if the {@link ServerCall} contains ALTS information.
   *
   * @param call the {@link ServerCall} to check
   * @return true, if the {@link ServerCall} contains ALTS information and false otherwise.
   */
  public static boolean check(ServerCall<?, ?> call) {
    return check(call.getAttributes());
  }

  /**
   * Checks if the {@link ClientCall} contains ALTS information.
   *
   * @param call the {@link ClientCall} to check

View on GitHub (pinned to 64daddc1f3)

Solutions

  1. Guard the call with AltsContextUtil.isAltsServerCall() (or check the attributes contain AltsProtocolNegotiator.AUTH_CONTEXT_KEY) before calling createFrom()
  2. Ensure both client and server use AltsChannelBuilder/AltsServerBuilder so the ALTS protocol negotiator is installed
  3. Wrap createFrom() in try-catch for IllegalArgumentException and fall back to non-ALTS peer-identity handling

Example fix

// before
AltsContext ctx = AltsContextUtil.createFrom(call.getAttributes());
// after
if (AltsContextUtil.isAltsServerCall(call.getAttributes())) {
  AltsContext ctx = AltsContextUtil.createFrom(call.getAttributes());
} else {
  // non-ALTS call: skip ALTS peer identity
}
Defensive patterns

Strategy: validation

Validate before calling

if (!AltsContextUtil.isAltsServerCall(call.getAttributes())) {
  throw new Status.UNAVAILABLE.withDescription("not an ALTS call").asRuntimeException();
}
AltsContext ctx = AltsContextUtil.createFrom(call.getAttributes());

Type guard

boolean isAlts = attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY) instanceof AltsInternalContext;

Try / catch

try {
  AltsContext ctx = AltsContextUtil.createFrom(attrs);
} catch (IllegalArgumentException e) {
  // non-ALTS transport; fall back to TLS peer identity or reject
}

Prevention

When it happens

Trigger: Calling AltsContextUtil.createFrom() on call attributes that did not come from an ALTS-negotiated channel — e.g. attributes from a plaintext or TLS channel, or calling it before the ALTS handshake populated the auth context.

Common situations: Developers using a shared interceptor across ALTS and non-ALTS servers call createFrom() unconditionally; or a server is configured without the ALTS protocol negotiator so the AUTH_CONTEXT_KEY is never attached.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of grpc/grpc-java@64daddc1f3 (2026-09-08). Data as JSON: /api/errors/97b79f78ec8f6c6b. Report an issue: GitHub.