{"record":{"id":"148d677d73034981","repo":"Tencent/WeKnora","slug":"model-is-currently-downloading","errorCode":null,"errorMessage":"model is currently downloading","messagePattern":"model is currently downloading","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/application/service/model.go","lineNumber":194,"sourceCode":"\t\treturn nil, err\n\t}\n\n\t// Check if model exists\n\tif model == nil {\n\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","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/model.go#L176-L212","documentation":"After fetching a model, GetModelByID only returns it when its status is ModelStatusActive. If the model row has status ModelStatusDownloading, the service refuses to serve it and returns errors.New(\"model is currently downloading\"), because the model binary/config is not yet usable for inference. This is a transient state error — retrying later can succeed once the download completes.","triggerScenarios":"Calling GetModelByID/GetEmbeddingModel/GetRerankModel while the model's background download is still in progress (model.Status == types.ModelStatusDownloading), e.g. immediately after registering/creating a model that was queued for download.","commonSituations":"A tenant creates a model and immediately an embedding request references it; a deployment races its first request against model provisioning; a scheduled job starts before the model manager finishes downloading; a stale UI shows the model as selectable while it is still downloading.","solutions":["Wait for the download to finish before using the model: poll the model status (e.g. via GetModelByID or a model list endpoint) until it becomes ModelStatusActive, then retry.","If the download is stuck, inspect the model manager/worker logs for download errors and restart or re-trigger the download job.","Add retry logic with backoff around calls that can hit this transient state, giving up after a timeout.","If the model is not actually downloading, fix the stale status in the persistence layer (reset the row or re-run provisioning)."],"exampleFix":"// before\nmodel, err := modelService.GetEmbeddingModel(ctx, modelID)\nif err != nil { return nil, err }\n// after\nvar model *types.Model\nfor i := 0; i < 30; i++ {\n    model, err = modelService.GetEmbeddingModel(ctx, modelID)\n    if err == nil { break }\n    if !strings.Contains(err.Error(), \"model is currently downloading\") { return nil, err }\n    time.Sleep(10 * time.Second)\n}","handlingStrategy":"retry","validationCode":"m, err := svc.GetModelByID(ctx, modelID)\nif err == nil && m.Status == types.ModelStatusDownloading {\n    // not ready yet — wait before calling again\n}","typeGuard":"func isModelReady(m *types.Model) bool { return m != nil && m.Status == types.ModelStatusActive }","tryCatchPattern":"model, err := svc.GetModelByID(ctx, modelID)\nif err != nil {\n    if strings.Contains(err.Error(), \"currently downloading\") {\n        // transient: schedule retry with backoff\n    }\n    return nil, err\n}","preventionTips":["Check model status before issuing inference requests right after provisioning.","Use retry with exponential backoff for transient downloading states.","Gate downstream jobs on model-active events rather than immediate calls.","Surface model download progress in UIs so users don't call not-yet-ready models."],"tags":["go","transient-state","model-download","retry"],"backgroundTag":"model-not-ready","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}