Skip to content

[BUG] Gateway reconcile panics when a provider has no env block #272

Closed

Description

@inference-gateway-maintainer

Summary

ProviderSpec.Env is an optional *[]corev1.EnvVar (api/v1alpha1/gateway_types.go L402-404), but updateProvidersSummary dereferences it unconditionally with range *p.Env (internal/controller/gateway_controller.go L276 and L296). Any provider with a supported name (for example ollama, which needs no API key Secret) and no env block makes every Gateway reconcile panic with a nil pointer dereference. The enabled check comes after the dereference (L305), so enabled: false does not avoid it. The panic happens in reconcileGatewayStatus after the Deployment, Service, routing, HPA and ServiceAccount have already been applied, so the workload comes up but status.url, status.providerSummary, status.mcpServers and status.a2aAgents are never written. controller-runtime recovers the panic and requeues the request with backoff indefinitely.

Steps to Reproduce

  1. In a namespace labeled inference-gateway.com/managed=true, apply a Gateway whose only provider is - name: ollama with enabled: true and no env.
  2. Check the operator logs: kubectl logs -n inference-gateway-system deployment/operator-inference-gateway.
  3. Check the Gateway status: kubectl get gateway <name> -o jsonpath='{.status}'.

Reproduced offline by calling GatewayReconciler.Reconcile against a controller-runtime fake client with that spec; it panics with runtime error: invalid memory address or nil pointer dereference at gateway_controller.go:276 (updateProvidersSummary <- reconcileGatewayStatus <- Reconcile).

Expected Behavior

A provider without env is treated like one with an empty list: it is skipped from status.providerSummary (no Secret to check), and the rest of the status is written normally.

Actual Behavior

Every reconcile of that Gateway fails with a recovered nil pointer panic, the operator logs the panic and retries with backoff forever, and the Gateway status beyond serviceAccountName stays empty.

Activity

  1. added
    bug
    on Oct 4, 2026
  2. edenreich commented on Oct 4, 2026

    @edenreich
    Contributor

    @claude can you work on this? use /ponytail:ponytail

  3. inference-gateway-maintainer commented on Oct 4, 2026

    @inference-gateway-maintainer
    ContributorAuthor

    Claude finished @edenreich's task in 4m 2s —— View job • fix/issue-272-20261004-1100 • [Create PR ➔](https://github.com/inference-gateway/operator/compare/main...fix/issue-272-20261004-1100?quick_pull=1&title=Issue%20%23272%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%23272%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)


    Fixed: nil ProviderSpec.Env panic

    • Read updateProvidersSummary and grep every .Env dereference
    • Add nil guard
    • Add regression tests
    • task test, task fmt, task vet, task lint (all pass, 0 lint issues)
    • Commit + open PR

    One guard before the first range *p.Env covers both loops - a provider with no env has no Secret to check, so it is skipped exactly like one with an unresolvable secret, and the rest of the status is written normally.

    if p.Env == nil {
    	logger.V(1).Info("Skipping provider without env", "provider", p)
    	continue
    }

    The other .Env reads in the controllers (gateway_controller.go:711 container env, agent_controller.go:375, orchestrator_controller.go:572) already nil-check, so nothing else needed changing.

    Tests added in gateway_controller_test.go: an env-less ollama provider yields an empty summary instead of panicking, and an enabled provider whose Secret holds the API key is still listed.

    skipped: treating env: [] and missing env differently, add when a provider needs status without a Secret.

    PR #278
    | fix/issue-272-20261004-1100

  4. moved this from QA to Done in 2026on Oct 4, 2026
  5. inference-gateway-releaser commented on Oct 4, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.27.1 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions