Skip to content

request-response-samples: err.root not set on non-Fault parse errors #45

@evans-sam

Description

@evans-sam

Summary

Two fixtures under `test/request-response-samples/` are currently skipped (via `SKIPPED_FIXTURES` in test/request-response-samples.test.ts) because they assert behavior that `src/wsdl/index.ts` doesn't currently implement. They were latent since the fork: the original mocha config used `--bail --exit`, and the test suite was never actually executing anyway (ERR_MODULE_NOT_FOUND from extensionless lib/ imports — see #43). The Bun migration made them visible.

Failing fixtures

  1. `fooOp__should_return_back_good_response_object` — `response.xml` has mismatched tags (intentional malformed XML); no `response.json` file. The fixture asserts `err.root === null`, but in `src/wsdl/index.ts` (around line 536), `error.root` is only set on SOAP-Fault paths. For generic parse failures, `error.root` is `undefined`.

  2. `SendCDATA__cdata_preserves_leading_and_trailing_whitespace_when_preserveWhitespace_option_is_true` — passes in isolation (`bun test --test-name-pattern="cdata preserves leading"`), fails only as collateral from test 1's state pollution (the shared server handler's deferred `assert.equal` fires against the wrong subsequent request after test 1's abort). Re-enabling this depends on fixing test 1 first.

Root cause

The fixture's intent: on any parse error, `err.root` should carry the parsed JSON of the response (or `null` if unparseable). Currently `err.root` is only populated on SOAP-Fault paths. For non-Fault parse errors (e.g., malformed XML), the caller has no way to inspect what came back.

Proposed fix

In `src/wsdl/index.ts`, set `error.root` consistently on all error paths constructed from a response — populate with the parsed JSON when available, `null` otherwise. Mirror the pattern to the Fault path so the shape is uniform.

Rough sketch:

```ts
// wherever a parse/process error is about to be thrown with the response context
error.root = responseJSON ?? null;
throw error;
```

Verification

  1. Remove the two entries from `SKIPPED_FIXTURES` in `test/request-response-samples.test.ts`.
  2. `bun test test/request-response-samples.test.ts` — all fixtures pass.
  3. No change to Fault-path behavior (confirm existing Fault fixtures still pass).

Context

Discovered during the Bun migration PR. Not a migration regression — the fixtures have been latent since the fork from node-soap. The migration commit that skipped them documents the reasoning:

```
commit 71e9dea
test: skip 2 pre-existing broken fixtures in request-response-samples
```

Related: #43 (extensionless ESM imports in published lib/).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions