plandex-ai/plandex · error
error hashing models: %v
Error message
error hashing models: %v
What it means
CustomModelsCheckLocalChanges computes a hash of the local ModelsInput via localModelsInput.Hash(); a hashing failure is wrapped as 'error hashing models: %v'. Hashing depends on serializing the model input, so this indicates the in-memory data cannot be canonicalized.
Source
Thrown at app/cli/lib/custom_models.go:126
}
var localClientModelsInput shared.ClientModelsInput
err = json.Unmarshal(localJsonData, &localClientModelsInput)
if err != nil {
return CustomModelsCheckLocalChangesResult{}, fmt.Errorf("error unmarshalling JSON file: %v", err)
}
localModelsInput := localClientModelsInput.ToModelsInput()
lastSavedHash, err := os.ReadFile(hashPath)
if err != nil && !os.IsNotExist(err) {
return CustomModelsCheckLocalChangesResult{}, fmt.Errorf("error reading hash file: %v", err)
}
currentHash, err := localModelsInput.Hash()
if err != nil {
return CustomModelsCheckLocalChangesResult{}, fmt.Errorf("error hashing models: %v", err)
}
return CustomModelsCheckLocalChangesResult{
HasLocalChanges: currentHash != string(lastSavedHash),
LocalModelsInput: localModelsInput,
}, nil
}
func WriteCustomModelsFile(path string, modelsInput *shared.ModelsInput) error {
err := os.MkdirAll(filepath.Dir(path), 0755)
if err != nil {
return fmt.Errorf("error creating directory: %v", err)
}
clientModelsInput := modelsInput.ToClientModelsInput()
clientModelsInput.PrepareUpdate()
jsonData, err := json.MarshalIndent(clientModelsInput, "", " ")View on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped hash error for the failing serialization reason
- Fix or remove the offending custom model/provider entries in the local JSON
- Delete local custom-models state and resync from the server to rebuild a clean input
- If reproducible with valid data, report/inspect the Hash implementation for the unsupported case
Example fix
// before
currentHash, err := localModelsInput.Hash()
if err != nil {
return CustomModelsCheckLocalChangesResult{}, fmt.Errorf("error hashing models: %v", err)
}
// after: caller resyncs on hash failure
if _, err := localModelsInput.Hash(); err != nil {
return SyncCustomModels() // rebuild local state from server
} Defensive patterns
Strategy: fallback
Validate before calling
if len(input.CustomModels) == 0 && len(input.CustomProviders) == 0 {
return // nothing to hash; skip comparison
} Try / catch
res, err := CustomModelsCheckLocalChanges(...)
if err != nil && strings.Contains(err.Error(), "error hashing models") {
// local input is unusable — rebuild it from the server
return SyncCustomModels()
} Prevention
- Ensure custom model entries are fully populated before writing local state
- Resync from the server whenever local JSON failed to parse
- Report reproducible hash failures on valid data as library bugs
When it happens
Trigger: localModelsInput.Hash() returns an error — e.g. the serialization step inside Hash fails because some model/provider entry in the local input cannot be marshalled deterministically (nil/invalid nested data).
Common situations: Corrupt or partially parsed entries from a malformed local JSON (feeding into the input); custom model definitions with unsupported field values; a bug/edge case in the Hash implementation for unusual model shapes.
Related errors
- error reading JSON file: %v
- error creating directory: %v
- error marshalling models: %v
- error hashing model pack: %v
- error marshalling current plan: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/f5b3f3c4406ca88c.
Report an issue: GitHub.