matcha icon indicating copy to clipboard operation
matcha copied to clipboard

BUG: Missing ok check on type assertion in HTTP tests

Open andrinoff opened this issue 7 months ago • 2 comments

Describe the bug

In plugin/http_test.go line 58, type assertion lacks ok check:

headers := tbl.RawGetString("headers").(*lua.LTable)

If headers field isn't *lua.LTable, panic occurs instead of proper error.

To reproduce

  1. Modify test to return non-table value for headers
  2. Test panics instead of failing gracefully
  3. No useful error message

Expected behavior

Use safe type assertion:

headersVal := tbl.RawGetString("headers")
headers, ok := headersVal.(*lua.LTable)
if !ok {
    t.Fatalf("expected headers to be table, got %T", headersVal)
}

Screenshots

N/A

Additional context

  • File: plugin/http_test.go
  • Line: 58
  • Severity: Medium - test crashes vs proper failure
  • Fix complexity: Easy - add ok check pattern

andrinoff avatar Apr 16 '26 20:04 andrinoff

This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.

floatpanebot avatar May 17 '26 05:05 floatpanebot

Closing due to inactivity. Reopen if still relevant.

floatpanebot avatar May 31 '26 06:05 floatpanebot