Skip to content

fix(api): resolve samlify's SamlLib under Node's ESM loader - #183

Merged
themightychris merged 3 commits into
developfrom
fix/samlify-esm-interop
Sep 18, 2026
Merged

themightychris merged 3 commits into
developfrom
fix/samlify-esm-interop

Conversation

@themightychris

Copy link
Copy Markdown
Member

The first signed-in Slack SSO attempt against the live site returned 500 internal_error (traceId 01a0b302-abe6-7f55-9ebd-32140e782e80):

TypeError: Cannot read properties of undefined (reading 'replaceTagsByValue')
    at replaceTagsByValue (dist/saml/config.js:91)

samlify is CommonJS. Under Node's ESM loader cjs-module-lexer does not detect SamlLib (re-exported through a getter), so import * as samlify leaves it undefined; only default (module.exports) carries it. vitest's interop exposes it as a named export, which is why all 19 SAML tests pass while production fails. Reproduced with plain node --input-type=module -e "import * as s from 'samlify'; …".

Fix: resolve from whichever view carries SamlLib. Verified by building and importing dist/saml/config.js under plain Node. Plan: plans/samlify-esm-interop.md (follow-up noted: a compiled-output smoke test in CI).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LFyA5poHwrhAktrnsKrUiQ

themightychris and others added 3 commits September 18, 2026 01:38
samlify is CommonJS and re-exports SamlLib through a getter that
cjs-module-lexer does not detect, so `import * as samlify` leaves it
undefined in the compiled build and every signed-in SSO attempt 500'd
with "Cannot read properties of undefined (reading 'replaceTagsByValue')".
vitest's interop exposes it as a named export, which is why the suite
never saw it. Take module.exports (the `default` view) when it carries
SamlLib.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LFyA5poHwrhAktrnsKrUiQ
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LFyA5poHwrhAktrnsKrUiQ
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LFyA5poHwrhAktrnsKrUiQ
@themightychris
themightychris merged commit 6436f60 into develop Sep 18, 2026
1 of 2 checks passed
@themightychris
themightychris deleted the fix/samlify-esm-interop branch September 18, 2026 05:44
@themightychris themightychris mentioned this pull request Sep 18, 2026
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.

1 participant