{"record":{"id":"83f8c3275e07d8f3","repo":"Tencent/WeKnora","slug":"bucket-q-does-not-exist-83f8c3","errorCode":null,"errorMessage":"bucket %q does not exist","messagePattern":"bucket %q does not exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/application/service/file/oss.go","lineNumber":160,"sourceCode":"\trest := strings.TrimPrefix(filePath, ossScheme)\n\tparts := strings.SplitN(rest, \"/\", 2)\n\tif len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid OSS file path: %s\", filePath)\n\t}\n\treturn parts[0], parts[1], nil\n}\n\n// CheckConnectivity verifies OSS is reachable and the main bucket exists.\nfunc (s *ossFileService) CheckConnectivity(ctx context.Context) error {\n\tcheckCtx, cancel := context.WithTimeout(ctx, 10*time.Second)\n\tdefer cancel()\n\n\texists, err := s.client.IsBucketExist(checkCtx, s.bucketName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to check OSS bucket: %w\", err)\n\t}\n\tif !exists {\n\t\treturn fmt.Errorf(\"bucket %q does not exist\", s.bucketName)\n\t}\n\treturn nil\n}\n\n// SaveFile saves a file to OSS using the Uploader manager for large files.\nfunc (s *ossFileService) SaveFile(ctx context.Context,\n\tfile *multipart.FileHeader, tenantID uint64, knowledgeID string,\n) (string, error) {\n\text := filepath.Ext(file.Filename)\n\tobjectName := fmt.Sprintf(\"%s%d/%s/%s%s\", s.pathPrefix, tenantID, knowledgeID, uuid.New().String(), ext)\n\n\tsrc, err := file.Open()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to open file: %w\", err)\n\t}\n\tdefer src.Close()\n\n\tcontentType := file.Header.Get(\"Content-Type\")","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/oss.go#L142-L178","documentation":"CheckConnectivity confirms the configured bucket exists via IsBucketExist; this error is returned when the OSS service responds successfully but reports that the bucket configured for this service (s.bucketName) does not exist. It is a definitive configuration/deployment problem, not a transient failure.","triggerScenarios":"Calling CheckConnectivity when the bucket name in configuration was never created, was deleted, is misspelled, or belongs to another account/region (bucket names are global per region).","commonSituations":"Fresh environment where infra-as-code hasn't created the bucket; typo in BUCKET_NAME config; bucket created in a different region than the endpoint used; bucket deleted or renamed; wrong account credentials that can't see the bucket.","solutions":["Create the missing bucket (via OSS console, ossutil mb oss://<bucket>, or IaC)","Verify the bucket name in service config matches an existing bucket and the endpoint/region matches the bucket's region","Confirm credentials belong to the account that owns (or has rights to) the bucket","Check for typos or stale environment variables (e.g. pointing at a dev bucket name in prod)"],"exampleFix":"// before (config)\nOSS_BUCKET=my-app-files   // bucket never created\n// after\n$ ossutil mb oss://my-app-files --region cn-hangzhou\nOSS_BUCKET=my-app-files","handlingStrategy":"validation","validationCode":"// Before starting the service, verify the bucket exists using the OSS SDK directly\nclient, _ := oss.New(endpoint, ak, sk)\nexists, err := client.IsBucketExist(ctx, cfg.Bucket)\nif err != nil { return err }\nif !exists { return fmt.Errorf(\"bucket %q missing; run: ossutil mb oss://%s\", cfg.Bucket, cfg.Bucket) }","typeGuard":null,"tryCatchPattern":"if err := svc.CheckConnectivity(ctx); err != nil {\n    if strings.Contains(err.Error(), \"does not exist\") {\n        log.Fatalf(\"fatal config error: create bucket %q first\", cfg.Bucket) // not retryable\n    }\n    return err\n}","preventionTips":["Provision the bucket in IaC (Terraform/CloudFormation/ossutil) before deploying the app","Add a startup health check that fails fast when the bucket is absent","Keep bucket-name config in one validated place; avoid per-environment typos","Ensure endpoint region matches the bucket's region"],"tags":["oss","configuration","missing-resource","bucket"],"backgroundTag":"bucket-does-not-exist","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}