---
id: w6/m9/t005
title: "Fix nil-pointer panic in SetAutoscaling/DisableAutoscaling GraphQL resolvers (red tests, pre-existing)"
worker: worker6
status: done
estimate: 30m
depends_on: []
---

## Objective

Fix the pre-existing nil-pointer panic behind `TestGraphQLSetAutoscalingMutation`/`TestGraphQLDisableAutoscalingMutation`, per `w6/008`.

## Context

- `lego/backend/internal/apps/autoscaling_test.go:260,282` — both tests fail at HEAD and on clean `main` (pre-existing, not caused by any recent milestone).
- Symptom: `res.Errors` carries a `runtime error: invalid memory address or nil pointer dereference` from a resolver panic.
- Likely culprit: `setAutoscaling`/`disableAutoscaling` GraphQL resolvers or the `SetAutoscaling`/`DisableAutoscaling` service methods they call (`apps/service.go`).

## Steps

1. Reproduce: `cd lego/backend && go test ./internal/apps/ -run 'TestGraphQLSetAutoscalingMutation|TestGraphQLDisableAutoscalingMutation' -v`.
2. Trace the nil dereference to its source (likely a resolver assuming a non-nil field that the test's fixture leaves nil).
3. Fix the nil-handling at the source (not just in the test).

## Files

- `lego/backend/internal/apps/autoscaling_test.go`
- `lego/backend/internal/apps/service.go` (or wherever the resolver/service method lives)

## Acceptance criteria

- [ ] Both tests pass.
- [ ] `cd lego/backend && go test ./...` is green.

## Out of scope

- Broader autoscaling feature work — this is a bug fix only.
