{"record":{"id":"954c1c3879a5bd8f","repo":"Tencent/WeKnora","slug":"resource-physical-path-has-unsupported-provider-sc","errorCode":null,"errorMessage":"resource physical path has unsupported provider scheme","messagePattern":"resource physical path has unsupported provider scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/resource.go","lineNumber":74,"sourceCode":"\t\treturn physicalPath, nil\n\t}\n\tlocationHash := resourceLocationHash(physicalPath)\n\texisting, err := s.repo.GetByTenantLocation(ctx, tenantID, locationHash)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif existing != nil {\n\t\treturn types.BuildResourcePath(existing.Handle), nil\n\t}\n\n\tbackendID, inner, scoped := types.ParseStorageBackendPath(physicalPath)\n\tproviderPath := physicalPath\n\tif scoped {\n\t\tproviderPath = inner\n\t}\n\tprovider := types.ParseProviderScheme(providerPath)\n\tif provider == \"\" {\n\t\treturn \"\", fmt.Errorf(\"resource physical path has unsupported provider scheme\")\n\t}\n\tlifecycle := types.ResourceLifecyclePersistent\n\tif meta.Temporary {\n\t\tlifecycle = types.ResourceLifecycleTemporary\n\t}\n\tfor attempt := 0; attempt < 4; attempt++ {\n\t\thandle, tokenErr := randomResourceToken()\n\t\tif tokenErr != nil {\n\t\t\treturn \"\", tokenErr\n\t\t}\n\t\tresource := &types.StoredResource{\n\t\t\tHandle:           handle,\n\t\t\tTenantID:         tenantID,\n\t\t\tStorageBackendID: backendID,\n\t\t\tProvider:         provider,\n\t\t\tPhysicalPath:     physicalPath,\n\t\t\tLocationHash:     locationHash,\n\t\t\tKind:             meta.Kind,","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/resource.go#L56-L92","documentation":"Register parses a provider scheme from the (possibly scope-stripped) physical path via types.ParseProviderScheme. If the path has no recognizable provider prefix (e.g. s3://, gcs://, local filesystem conventions), the resource cannot be attributed to a storage provider and registration fails.","triggerScenarios":"Calling Register with a bare relative path like 'uploads/file.pdf' or a URL with an unknown/typo scheme ('s3a://bucket/x' if unsupported, 'file' without '//' form the parser rejects).","commonSituations":"Constructing physical paths by string concatenation and forgetting the provider prefix; switching storage backends and leaving old unprefixed paths; custom schemes not registered with ParseProviderScheme.","solutions":["Prefix the physical path with a supported provider scheme, e.g. 's3://bucket/key' or the local-store scheme used by your deployment.","Check types.ParseProviderScheme to see which schemes are recognized in this version.","Normalize legacy paths through a migration helper that adds the correct scheme.","Update the code path that builds paths so the provider scheme is always included at construction time."],"exampleFix":"// before\nphysicalPath := fmt.Sprintf(\"%s/%s\", bucket, key) // \"mybucket/docs/a.pdf\"\n// after\nphysicalPath := fmt.Sprintf(\"s3://%s/%s\", bucket, key) // \"s3://mybucket/docs/a.pdf\"","handlingStrategy":"validation","validationCode":"if types.ParseProviderScheme(strings.TrimSpace(physicalPath)) == \"\" {\n    return fmt.Errorf(\"path %q needs a provider scheme (e.g. s3://)\", physicalPath)\n}","typeGuard":"func hasProviderScheme(p string) bool { return types.ParseProviderScheme(p) != \"\" }","tryCatchPattern":"id, err := svc.Register(ctx, tenantID, path, meta)\nif err != nil && strings.Contains(err.Error(), \"unsupported provider scheme\") {\n    return nil, fmt.Errorf(\"cannot register %q: %w\", path, err)\n}","preventionTips":["Always build physical paths with the provider prefix (s3://, gcs://, etc.)","Check ParseProviderScheme for the list of supported schemes in your version","Migrate legacy unprefixed paths once, centrally"],"tags":["validation","resource","storage","scheme"],"backgroundTag":"unsupported-provider-scheme","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}