Skip to content

[Bug]: createModel GraphQL mutation panics with nil pointer when channel has no endpoints #1752

@deng1986

Description

@deng1986

Version

v1.0.0-beta1 (commit 3ed308ef, 2026-05-23)

Summary

The createModel GraphQL mutation triggers a nil pointer panic in ModelService.CreateModel (internal/server/biz/model.go:291) when the model association references a channel that was created without explicit endpoints.

Steps to Reproduce

  1. Initialize AxonHub, create a channel via GraphQL WITHOUT setting endpoints:
mutation {
  createChannel(input: {
    type: deepseek
    name: "DeepSeek"
    credentials: { apiKey: "sk-xxx" }
    supportedModels: ["deepseek-chat"]
    defaultTestModel: "deepseek-chat"
  }) { id }
}
  1. Enable the channel.

  2. Try to create a model with a channelModel association to that channel:

mutation {
  createModel(input: {
    developer: "DeepSeek"
    modelID: "deepseek-chat"
    name: "DeepSeek Chat"
    icon: "deepseek"
    group: "DeepSeek"
    modelCard: { toolCall: true, temperature: true }
    settings: {
      associations: [{
        type: "channelModel"
        channelModel: { channelId: 1, modelId: "deepseek-chat" }
      }]
    }
  }) { id }
}
  1. Response: {"errors": [{"message": "internal system error"}]}

Stack Trace

panic({0x107b649c0?, 0x1084c3080?})
    /opt/hostedtoolcache/go/1.26.3/x64/src/runtime/panic.go:860 +0x12c
github.com/looplj/axonhub/internal/server/biz.(*ModelService).CreateModel(...)
    /home/runner/work/axonhub/axonhub/internal/server/biz/model.go:291 +0x4a4
github.com/looplj/axonhub/internal/server/gql.(*mutationResolver).CreateModel(...)
    /home/runner/work/axonhub/axonhub/internal/server/gql/model.resolvers.go:26 +0x58

The panic is caught by gqlgen's recovery middleware → returns "internal system error" to the client. Server stays alive.

Root Cause Analysis

Likely related to #1746 — channels created without explicit endpoints have endpoints: null. When createModel processes a channelModel association, it dereferences the channel's endpoints without a nil guard, causing the panic.

#1746 fixed the frontend Zod validation (allowing endpoints: null), but the backend was not hardened.

Workaround

Unknown — cannot create models via GraphQL API when channels have no endpoints. Web UI model creation may or may not be affected (untested).

Environment

  • OS: macOS arm64
  • Deployment: single binary, SQLite
  • Go version: 1.26.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions