Skip to content

fix(storage): route persisted paths to inferred provider - #4891

Open
LuckVd wants to merge 1 commit into
Tencent:mainfrom
LuckVd:fix/4889-s3-storage-routing
Open

LuckVd wants to merge 1 commit into
Tencent:mainfrom
LuckVd:fix/4889-s3-storage-routing

Conversation

@LuckVd

@LuckVd LuckVd commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #4889. When a knowledge base's configured storage provider differs from a persisted file path, the old mismatch fallback could send an S3 path to the process-wide local file service, producing a local ENOENT such as /data/files/s3:/.... I resolve the provider inferred from the path using tenant storage configuration and normalize legacy single-slash provider URIs before routing; the local service now rejects remote provider paths rather than treating them as disk paths (internal/application/service/knowledge_util.go:444, internal/types/knowledgebase.go:533, internal/application/service/file/local.go:326).

Change

  • Route mismatched persisted paths to their inferred storage provider, including legacy paths normalized by filepath.Clean.
  • Normalize legacy single-slash provider URIs for path parsing and reject non-local provider schemes in local file operations.
  • Add regression coverage for provider routing, S3 path parsing, and local-service rejection of remote paths.

Scope note

No unrelated packages or independent Go modules were changed.

Type of Change

  • 🐛 Bug fix

Related Issue

Testing

  • go test -count=1 ./internal/types -run '^(TestParseProviderScheme|TestInferStorageFromFilePath)$' — pass
  • go test -count=1 ./internal/application/service/file -run '^(TestStorageBackendInnerPath|TestParseS3FilePathAcceptsCanonicalBackendPath|TestLocalGetFileRejectsNonLocalProviderSchemes)$' — pass
  • go test -count=1 ./internal/application/service -run '^TestResolveFileServiceForPathUsesPathProviderOnConfigMismatch$' — pass
  • go build ./internal/types ./internal/application/service/file ./internal/application/service — pass
  • go vet ./internal/types ./internal/application/service/file ./internal/application/service — clean
  • gofmt -l on changed Go files — no output; git diff --check origin/main...HEAD — clean
  • I did not run the full repository test suite locally; verification was scoped to the affected packages. golangci-lint was unavailable locally; GitHub CI will run the repository checks.

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint (golangci-lint) was not run locally; see Testing
  • Full-repository checks were not run locally; see Testing
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (not applicable to this code-only fix)
  • Breaking changes are clearly called out above: none

Screenshots / Recordings

Not applicable (no user-visible UI changes).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Local-storage fallback in resolveFileServiceForPath makes parsing fail with ENOENT (/data/files/s3:/...) for S3/MinIO-backed files

1 participant