Skip to content

fix: correct malformed WASM binary and stale test expectation in guard tests#1849

Merged
lpcox merged 2 commits intomainfrom
fix/wasm-test-binary
Mar 13, 2026
Merged

fix: correct malformed WASM binary and stale test expectation in guard tests#1849
lpcox merged 2 commits intomainfrom
fix/wasm-test-binary

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Mar 13, 2026

Summary

Fixes two failing tests in internal/guard/wasm_test.go.

1. Malformed WASM binary (TestWasmGuardContextPropagation)

The hand-crafted blockingGuardWasm byte array had incorrect section lengths:

  • Type section header: 0x07 (7 bytes) but only 4 bytes followed
  • Export section: 1 byte short
  • Code section: missing loop block type and too few bytes

Rebuilt as a correct 39-byte WASM binary for (module (func (export "loop") (loop (br 0)))).

2. Stale test expectation (TestParsePathLabeledResponse)

parsePathLabeledResponse with empty labeled_paths and nil original data now succeeds (returns empty collection) after the NewPathLabeledData behavior change. Updated the test to expect success instead of error.

Testing

make agent-finished passes.

…d tests

- Fix blockingGuardWasm: type section header claimed 7 bytes but had 4;
  rebuilt correct 39-byte WASM binary for (module (func (export "loop") (loop (br 0))))
- Fix TestParsePathLabeledResponse: empty labeled_paths with nil data
  no longer errors after NewPathLabeledData behavior change

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 13, 2026 15:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes failing WASM guard tests by correcting an embedded WASM binary used for context-cancellation testing and updating a test expectation around path-based labeling parsing.

Changes:

  • Rebuilds blockingGuardWasm into a valid WASM binary (fixing section sizes and code body bytes).
  • Updates TestParsePathLabeledResponse to expect success (not error) when labeled_paths is empty and originalData is nil.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit a27f9a6 into main Mar 13, 2026
11 checks passed
@lpcox lpcox deleted the fix/wasm-test-binary branch March 13, 2026 15:46
lpcox added a commit that referenced this pull request Mar 15, 2026
…w error wrapping (#1929)

## Summary

Addresses the High and Medium priority findings from the
[BurntSushi/toml Go module
review](#1849).

## Changes

### Remove dead `*toml.ParseError` pointer assertion (`config_core.go`)

`toml.Decode` always returns `ParseError` as a **value type**, so the
`err.(*toml.ParseError)` pointer assertion could never match. This was
misleading dead code with a stale comment claiming it was needed for
"compatibility".

### Use `%w` wrapping for richer parse error messages

Replaced:
```go
return nil, fmt.Errorf("failed to parse TOML at line %d, column %d: %s",
    perr.Position.Line, perr.Position.Col, perr.Message)
```

With:
```go
return nil, fmt.Errorf("failed to parse TOML: %w", perr)
```

This surfaces `ParseError.Error()`'s full formatted output — including
the TOML source line and a `^` column pointer — giving users much better
context when their config has a syntax error. It also preserves the
structured `ParseError` type for callers using `errors.As`.

**Before:**
```
failed to parse TOML at line 5, column 12: expected value but found 'x'
```

**After:**
```
failed to parse TOML:

    5 | port = x
               ^
Error: expected value but found 'x'
```

### Update package doc comment

Reflects the new error-wrapping approach instead of the old manual field
extraction.

## Testing

All unit and integration tests pass (`make agent-finished`).
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.

2 participants