Skip to content

fix: auth plugin loginAs injection broken in 4.x#5502

Open
DavertMik wants to merge 1 commit into4.xfrom
fix/auth-plugin-loginAs-injection
Open

fix: auth plugin loginAs injection broken in 4.x#5502
DavertMik wants to merge 1 commit into4.xfrom
fix/auth-plugin-loginAs-injection

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Summary

  • Fix Container.support(name) to return plugin-injected functions directly instead of wrapping them in a non-callable Proxy. The 4.x ESM migration changed this method to always go through the proxy's lazyLoad(), which creates new Proxy({}, {...}) — designed for page object property access, not for calling functions. This broke the auth plugin's loginAs/login injection.
  • Fix proxy get and getOwnPropertyDescriptor handlers to also return functions directly (covers destructuring paths like container.support()['loginAs']).
  • Fix inject.js missing-key detection: !objects[key] never fired because lazyLoad() always returns a truthy Proxy. Changed to !(key in objects) which uses the proxy's has trap.

Root Cause

Container.support(name) was changed from:

// 3.x — works
return container.support[name] || container.proxySupport[name]

to:

// 4.x — broken for functions
return container.proxySupport[name]

The proxy's lazyLoad() returns new Proxy({}, { get... }) which has no apply trap and target {} is not callable. Page objects work fine (they use property access), but injected functions (like auth's loginAs) need to be called directly.

Test plan

  • New unit test: function injected via container.append({ support }) is returned as a callable function
  • All 33 container unit tests pass
  • Full unit test suite passes (7 pre-existing AI SDK failures unrelated)
  • Manual verification with auth plugin config using inject: "loginAs"

🤖 Generated with Claude Code

… of wrapping in non-callable Proxy

The 4.x ESM migration changed Container.support(name) to always go through
the proxy, which wraps values in lazyLoad() — a Proxy designed for page
objects (property access), not callable functions. This broke the auth
plugin's loginAs/login injection since the returned Proxy has no apply trap.

Also fixes missing-key detection in inject.js (was never firing because
lazyLoad always returns a truthy Proxy).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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