Ethan-Xingyue opened a new issue, #1177: URL: https://github.com/apache/incubator-seata-go/issues/1177
## 🚀 Go Version go1.24.3 darwin/arm64 ## 📦 Seata-go Version master, commit 3bf73586af81db1bd428982c93d82000d80cb1c8 (fetched 2026-09-02) ## 💾 Operating System macOS ## 📝 Bug Description `resolverFilePath` splits the file name on `.` and always takes index 1 as the format suffix: https://github.com/apache/incubator-seata-go/blob/3bf73586af81db1bd428982c93d82000d80cb1c8/pkg/client/config.go#L170-L177 For `seatago.prod.yaml` the suffix becomes `prod`, and `client.LoadPath` / `client.InitPath` (https://github.com/apache/incubator-seata-go/blob/3bf73586af81db1bd428982c93d82000d80cb1c8/pkg/client/client.go#L51) panic with `no support prod file suffix`. Any legitimate basename with an extra dot (environment or version suffixes, `app.v2.yml`, ...) cannot be loaded, and the failure is a panic at startup rather than an error. Suggested priority: P2 (small fix, but `LoadPath`/`InitPath` is the startup entry point). ## 🔄 Steps to Reproduce 1. Check out the commit and create a throwaway module that points at the local checkout: ```bash git clone https://github.com/apache/incubator-seata-go.git cd incubator-seata-go git checkout 3bf73586af81db1bd428982c93d82000d80cb1c8 repo_root="$(pwd)" repro_dir="$(mktemp -d)" cd "$repro_dir" go mod init seata-repro go mod edit -require=seata.apache.org/seata-go/[email protected] go mod edit -replace=seata.apache.org/seata-go/v2="$repo_root" ``` 2. Save the following as `repro_test.go` in `$repro_dir`: ```go package repro import ( "os" "path/filepath" "testing" "seata.apache.org/seata-go/v2/pkg/client" ) func TestConfigFilenameMayContainDots(t *testing.T) { path := filepath.Join(t.TempDir(), "seatago.prod.yaml") if err := os.WriteFile(path, []byte("seata: {}\n"), 0o600); err != nil { t.Fatal(err) } defer func() { if r := recover(); r != nil { t.Fatalf("valid .yaml filename panicked: %v", r) } }() _ = client.LoadPath(path) } ``` 3. Run: ```bash go mod tidy go test -run '^TestConfigFilenameMayContainDots$' -count=1 -v ``` ## ✅ Expected Behavior The file is loaded as YAML based on its last extension. Dots elsewhere in the basename do not affect format detection, and genuinely unsupported formats produce a diagnosable error rather than a panic or an index out of range. ## ❌ Actual Behavior ```text === RUN TestConfigFilenameMayContainDots repro_test.go:18: valid .yaml filename panicked: no support prod file suffix --- FAIL: TestConfigFilenameMayContainDots (0.00s) FAIL FAIL seata-audit-repros/cfg001 0.766s FAIL ``` (The package name in the last line comes from the multi-package scratch module the test was run in; with the steps above it reads `seata-repro`.) ## 💡 Possible Solution - Use `filepath.Base`, `filepath.Ext` and `strings.TrimSuffix`; compare the extension case-insensitively. - Add table-driven tests for `seatago.yaml`, `seatago.prod.yaml`, hidden files, no extension, upper-case extensions and Windows-style paths. - Longer term, offer error-returning variants (`LoadPathE` / `InitPathE`) so library code does not panic on user configuration. Acceptance criteria: - [ ] The test above passes. - [ ] Table covers single/multiple dots, `.yaml` / `.yml` / `.json` / `.toml`, upper case, no extension, hidden files and Windows-style paths. - [ ] Unsupported formats return a clear error; the existing panicking public API has a documented migration path. - [ ] Existing client initialisation tests still pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
