fix: access correct discoveryInfo property from ObjectStackClient#430
fix: access correct discoveryInfo property from ObjectStackClient#430
discoveryInfo property from ObjectStackClient#430Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The ObjectStackAdapter.getDiscovery() was accessing `this.client.discovery` which doesn't exist on @objectstack/client v2.0.1. The correct private property name is `discoveryInfo`. This caused getDiscovery() to always return null, making ConditionalAuthWrapper default auth to enabled, showing the login page even when auth.enabled=false in server discovery. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
discoveryInfo property from ObjectStackClient
There was a problem hiding this comment.
Pull request overview
Fixes ObjectStackAdapter.getDiscovery() to read the correct cached discovery field from @objectstack/client v2.0.1 so downstream auth gating can respect services.auth.enabled.
Changes:
- Update
getDiscovery()to readthis.client.discoveryInfoinstead of the non-existentthis.client.discovery. - Add Vitest coverage for
getDiscovery()success (auth disabled) and failure (returns null).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/data-objectstack/src/index.ts | Fixes discovery cache property access to discoveryInfo so discovery-based behavior (e.g., auth enablement) works. |
| packages/data-objectstack/src/connection.test.ts | Adds tests covering getDiscovery() returning cached discovery and null on connection failure. |
| // Mock the underlying client's connect method and discoveryInfo property | ||
| const client = adapter.getClient(); | ||
| vi.spyOn(client, 'connect').mockResolvedValue(mockDiscovery as any); | ||
| // Simulate what connect() does: sets discoveryInfo | ||
| (client as any).discoveryInfo = mockDiscovery; | ||
|
|
There was a problem hiding this comment.
The first getDiscovery test sets client.discoveryInfo before calling adapter.getDiscovery(), so it would still pass even if getDiscovery() stopped calling connect() (regression). Consider mocking client.connect with an implementation that sets discoveryInfo when invoked, and assert the spy was called, so the test actually verifies the connect→cache→read flow.
ObjectStackAdapter.getDiscovery()accessedthis.client.discovery, which doesn't exist on@objectstack/clientv2.0.1. The actual private field isdiscoveryInfo. This causedgetDiscovery()to always returnnull, soConditionalAuthWrapperdefaulted auth to enabled — showing the login page regardless of the server'sauth.enabledsetting.Changes
packages/data-objectstack/src/index.ts: Fix property access from.discoveryto.discoveryInfopackages/data-objectstack/src/connection.test.ts: Add tests forgetDiscovery()covering successful discovery retrieval (withauth.enabled: false) and connection failure fallback💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.