fix: improve error handling and nil consistency in FormatArgsJSON
- Use fmt.Sprintf fallback instead of {} on encoding errors
- Normalize nil args to {} in FormatArgsJSON for consistent output
- Update tests to expect {} instead of null for nil args
Based on PR #2670 review feedback from afjcjsbx
This commit is contained in:
1 parent
97b1c3efec
commit
8dca2a1319
4 files changed
+9
-7
No files matched your search
@@ -143,7 +143,7 @@ func TestFormatArgsJSON_EscapeHTMLByDefault(t *testing.T) {
|
||||
|
||||
func TestFormatArgsJSON_NilArgs(t *testing.T) {
|
||||
got := FormatArgsJSON(nil, false, false)
|
||||
want := `null`
|
||||
want := `{}`
|
||||
if got != want {
|
||||
t.Fatalf("FormatArgsJSON() nil = %q, want %q", got, want)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user