{"record":{"id":"3c8d9c76abbc9613","repo":"Tencent/WeKnora","slug":"model-download-failed","errorCode":null,"errorMessage":"model download failed","messagePattern":"model download failed","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/model.go","lineNumber":199,"sourceCode":"\t\tlogger.Error(ctx, \"Model not found\")\n\t\treturn nil, ErrModelNotFound\n\t}\n\n\tlogger.Infof(ctx, \"Model found, name: %s, status: %s\", model.Name, model.Status)\n\n\t// Check model status\n\tif model.Status == types.ModelStatusActive {\n\t\treturn model, nil\n\t}\n\n\tif model.Status == types.ModelStatusDownloading {\n\t\tlogger.Warn(ctx, \"Model is currently downloading\")\n\t\treturn nil, errors.New(\"model is currently downloading\")\n\t}\n\n\tif model.Status == types.ModelStatusDownloadFailed {\n\t\tlogger.Error(ctx, \"Model download failed\")\n\t\treturn nil, errors.New(\"model download failed\")\n\t}\n\n\tlogger.Error(ctx, \"Model status is abnormal\")\n\treturn nil, errors.New(\"abnormal model status\")\n}\n\n// ListModels returns all models belonging to the tenant\nfunc (s *modelService) ListModels(ctx context.Context) ([]*types.Model, error) {\n\tlogger.Info(ctx, \"Start listing models\")\n\n\ttenantID := types.MustTenantIDFromContext(ctx)\n\tlogger.Infof(ctx, \"Listing models for tenant ID: %d\", tenantID)\n\n\t// List models from repository with no additional filters\n\tmodels, err := s.repo.List(ctx, tenantID, \"\", \"\")\n\tif err != nil {\n\t\tlogger.ErrorWithFields(ctx, err, map[string]interface{}{\n\t\t\t\"tenant_id\": tenantID,","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/model.go#L181-L217","documentation":"When the fetched model's status is ModelStatusDownloadFailed, GetModelByID returns errors.New(\"model download failed\") because the model was provisioned but its download errored out and it can never serve requests in that state. Unlike the downloading case, this is a persistent failure that requires intervention: the download must be re-triggered.","triggerScenarios":"Calling GetModelByID/GetEmbeddingModel/GetRerankModel for a model whose persisted status is types.ModelStatusDownloadFailed — e.g. after a network failure, disk-full condition, or crash during model download.","commonSituations":"Offline/air-gapped deployments where the model artifact URL is unreachable; transient network outages during first provisioning; insufficient disk space on the worker; proxy/firewall blocking the model registry host; the model source URL changed or was removed upstream.","solutions":["Check the model manager/download worker logs for the root-cause error (network, 404, disk space) at the time the download failed.","Fix the underlying cause (network access, free disk space, correct model source URL/credentials) and re-trigger the model download to move it back to downloading/active.","Delete and re-create (re-register) the model entry if the download job cannot be resumed, then wait for it to reach active status.","Add monitoring/alerting on ModelStatusDownloadFailed so failures are caught and retried automatically rather than surfacing as request errors."],"exampleFix":"// before\nmodel, err := modelService.GetRerankModel(ctx, modelID) // fails: download failed\n// after\nif err := modelManager.RetryDownload(ctx, modelID); err != nil { return nil, err }\nif err := modelManager.WaitUntilActive(ctx, modelID, 5*time.Minute); err != nil { return nil, err }\nmodel, err := modelService.GetRerankModel(ctx, modelID)","handlingStrategy":"fallback","validationCode":"m, err := svc.GetModelByID(ctx, modelID)\nif err == nil && m.Status == types.ModelStatusDownloadFailed {\n    // do not call; repair/re-download first\n}","typeGuard":"func isDownloadFailed(m *types.Model) bool { return m != nil && m.Status == types.ModelStatusDownloadFailed }","tryCatchPattern":"model, err := svc.GetModelByID(ctx, modelID)\nif err != nil {\n    if strings.Contains(err.Error(), \"download failed\") {\n        return nil, fmt.Errorf(\"model %s is broken; re-trigger its download\", modelID)\n    }\n    return nil, err\n}","preventionTips":["Monitor for ModelStatusDownloadFailed and alert instead of letting requests fail.","Verify network/disk/artifact-URL requirements before provisioning models.","Expose a re-download/repair action for failed models.","Never retry blindly — this state is persistent until the download is re-run."],"tags":["go","model-download","provisioning","persistent-failure"],"backgroundTag":"model-download-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}