WeKnora/internal/application/service/file
Fei.Chen bca3a9f448
fix(storage): use virtual-hosted addressing for OBS bucket requests (#3273)
* fix(storage): use virtual-hosted addressing for OBS bucket requests

Huawei Cloud OBS has rejected path-style bucket addressing on domain
endpoints since 2023-12-30, so PutObject failed with 404 NoSuchKey while
HeadBucket still passed. The driver also pinned HostnameImmutable=true
via a deprecated custom endpoint resolver, which blocked the SDK from
injecting the bucket label into the hostname.

- Replace the custom resolver with BaseEndpoint and enable
  virtual-hosted style for domain endpoints; keep path-style as a
  defensive fallback for IP-literal or unparseable endpoints.
- Align checksum negotiation with the S3 driver
  (RequestChecksumCalculation: WhenRequired).
- GetFileURL now emits {bucket}.{endpoint-host}/{key} URLs when no
  proxy domain is configured, mirroring the client addressing.
- Share one obsS3Options constructor between the file service and the
  connectivity check, and add obs_test.go (previously zero coverage).

Closes #3269

* test(storage): assert OBS PutObject hits virtual-hosted URLs

UsePathStyle=false is not sufficient — a HostnameImmutable resolver can still force path-style. Capture the signed request host/path so this cannot regress the way #3272 would have.

* test(storage): keep OBS client tests within lint limits

The new-from-rev pre-push lint also flags the original obs_test.go lines. Wrap long fatals and silence the deprecated EndpointResolver assertion so the fork push can run hooks.

---------

Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-15 18:18:40 +08:00
..
backend_scoped.go feat(storage): add multi-instance storage backends per workspace 2026-07-15 14:54:39 +08:00
backend_scoped_test.go feat(storage): add multi-instance storage backends per workspace 2026-07-15 14:54:39 +08:00
cos.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
cos_parse_test.go feat: enhance IM file service tests and refactor storage URL handling 2026-05-29 13:47:32 +08:00
dummy.go feat(resource): add stable resource registry with LLM-context alias compaction 2026-07-15 17:02:43 +08:00
endpoint_security_test.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
errors.go fix: deep-copy stored files and images when cloning a knowledge base 2026-06-03 14:45:59 +08:00
factory.go fix(security): reject traversal in local prefixes, task IDs, and wiki sort 2026-09-07 11:23:45 +08:00
ks3.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
local.go fix: harden document pipeline concurrency and diagnostics 2026-07-09 13:26:40 +08:00
local_copy_test.go fix: deep-copy stored files and images when cloning a knowledge base 2026-06-03 14:45:59 +08:00
local_test.go fix(im): revert tenant-from-context for presigned URL 2026-04-30 11:40:30 +08:00
minio.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
obs.go fix(storage): use virtual-hosted addressing for OBS bucket requests (#3273) 2026-09-15 18:18:40 +08:00
obs_test.go fix(storage): use virtual-hosted addressing for OBS bucket requests (#3273) 2026-09-15 18:18:40 +08:00
oss.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
oss_test.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00
resolve_tenant.go refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00
resource_catalog.go feat(agent): preview skill artifacts and verify installs without running them (#2823) 2026-08-27 10:30:32 +08:00
resource_catalog_test.go feat(agent): preview skill artifacts and verify installs without running them (#2823) 2026-08-27 10:30:32 +08:00
s3.go fix(s3): disable optional checksums for compatible endpoints 2026-08-31 12:25:33 +08:00
s3_test.go fix(s3): disable optional checksums for compatible endpoints 2026-08-31 12:25:33 +08:00
tos.go fix(security): harden outbound URL SSRF protection (#2626) 2026-08-10 13:24:14 +08:00