Affected package or area
@sapiom/core header utilities (packages/core/src/utils/utils.ts)
Affected version, release, or commit
Current main at sapiom/sapiom-js as of 2026-08-13.
Environment
Node.js: 20+ / 22+
Package manager and version: pnpm 10.34.3
Operating system: platform-independent
Runtime or framework: header maps passed through SDK HTTP integrations
Minimal reproduction and steps
The helpers accept Record<string, string | string[] | undefined>, where undefined represents an omitted header in Node/HTTP-style maps.
import { setHeader, removeHeader } from "@sapiom/core";
const headers = {
Authorization: undefined,
"Content-Type": "text/plain",
};
setHeader(headers, "X-Sapiom-Transaction-Id", "tx_123");
removeHeader(headers, "Content-Type");
Expected behavior
Unrelated headers with undefined values should remain omitted when copying headers into the returned object. The returned header map should not contain Authorization in the example above.
Actual behavior
Both setHeader and removeHeader copy unrelated headers with this expression:
newHeaders[key] = Array.isArray(val) ? val[0] || "" : val || "";
That coerces undefined to "", turning an absent header into a present-but-empty header. Downstream HTTP clients can then send an empty Authorization or similar header instead of omitting it.
Logs, screenshots, and additional context
This is separate from #10, which normalized a completely missing request.headers object in @sapiom/node-http. This report is about individual undefined values inside an existing header object in @sapiom/core utilities. A focused fix would skip val === undefined while copying non-target headers and add regression tests in packages/core/src/utils/utils.test.ts.
Acknowledgements
Affected package or area
@sapiom/core header utilities (
packages/core/src/utils/utils.ts)Affected version, release, or commit
Current
mainatsapiom/sapiom-jsas of 2026-08-13.Environment
Node.js: 20+ / 22+
Package manager and version: pnpm 10.34.3
Operating system: platform-independent
Runtime or framework: header maps passed through SDK HTTP integrations
Minimal reproduction and steps
The helpers accept
Record<string, string | string[] | undefined>, whereundefinedrepresents an omitted header in Node/HTTP-style maps.Expected behavior
Unrelated headers with
undefinedvalues should remain omitted when copying headers into the returned object. The returned header map should not containAuthorizationin the example above.Actual behavior
Both
setHeaderandremoveHeadercopy unrelated headers with this expression:That coerces
undefinedto"", turning an absent header into a present-but-empty header. Downstream HTTP clients can then send an emptyAuthorizationor similar header instead of omitting it.Logs, screenshots, and additional context
This is separate from #10, which normalized a completely missing
request.headersobject in@sapiom/node-http. This report is about individualundefinedvalues inside an existing header object in@sapiom/coreutilities. A focused fix would skipval === undefinedwhile copying non-target headers and add regression tests inpackages/core/src/utils/utils.test.ts.Acknowledgements