Skip to content

chore: deduplicate BUG panic pattern for invalid-model domain computation across engine files #30275

@github-actions

Description

@github-actions

Problem

Three engine implementation files contain an identical panic message for the same logical condition — an invalid model reaching domain computation after it should have been caught by validation:

  • pkg/workflow/pi_engine.go:343
  • pkg/workflow/crush_engine.go:183
  • pkg/workflow/opencode_engine.go:141

All three contain:

panic(fmt.Sprintf("BUG: invalid model %q reached domain computation (should have been caught by validation): %v", model, err))

Each is triggered by the same call pattern — a call to GetAllowedDomainsForEngineWithModel that returns an error.

Impact

  • Copy-paste risk: A future fix to the wording must be applied to three separate files
  • Validation gap signal: Each engine individually guards against the same class of programmer error, suggesting model validation is not unified
  • Maintenance burden: Adding a fourth engine requires remembering to add the same guard

Recommendation

Option A — Shared panic helper (minimal change):

Introduce a mustGetAllowedDomainsForEngineWithModel(...) wrapper in a shared file that centralizes the panic, and replace all three call sites.

Option B — Upstream validation (better long-term):

Move model validation into the compilation pipeline so an invalid model is caught as an error before reaching any engine-specific code, eliminating the per-engine guard.

Validation

  • All three engine files updated or guard centralized
  • Existing tests pass
  • New engine implementations inherit validation automatically

Estimated Effort: Small
Severity: Low


Generated by Sergo — Run §25358281228

Generated by Sergo - Serena Go Expert · ● 755.5K ·

  • expires on May 12, 2026, 4:59 AM UTC

Metadata

Metadata

Labels

cookieIssue Monster Loves Cookies!sergo

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions