Skip to content

fix: access correct discoveryInfo property from ObjectStackClient#430

Merged
hotlong merged 2 commits intomainfrom
copilot/fix-login-page-display
Feb 10, 2026
Merged

fix: access correct discoveryInfo property from ObjectStackClient#430
hotlong merged 2 commits intomainfrom
copilot/fix-login-page-display

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 10, 2026

ObjectStackAdapter.getDiscovery() accessed this.client.discovery, which doesn't exist on @objectstack/client v2.0.1. The actual private field is discoveryInfo. This caused getDiscovery() to always return null, so ConditionalAuthWrapper defaulted auth to enabled — showing the login page regardless of the server's auth.enabled setting.

Changes

  • packages/data-objectstack/src/index.ts: Fix property access from .discovery to .discoveryInfo
  • packages/data-objectstack/src/connection.test.ts: Add tests for getDiscovery() covering successful discovery retrieval (with auth.enabled: false) and connection failure fallback
- // @ts-expect-error - Accessing internal discovery property
- return this.client.discovery || null;
+ // @ts-expect-error - Accessing internal discoveryInfo property
+ return this.client.discoveryInfo || null;

💡 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.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Error Error Feb 10, 2026 10:59am
objectui-console Ready Ready Preview, Comment Feb 10, 2026 10:59am
objectui-storybook Ready Ready Preview, Comment Feb 10, 2026 10:59am

Request Review

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>
Copilot AI changed the title [WIP] Fix console display of login page when auth is disabled fix: access correct discoveryInfo property from ObjectStackClient Feb 10, 2026
Copilot AI requested a review from hotlong February 10, 2026 10:36
@hotlong hotlong marked this pull request as ready for review February 10, 2026 10:40
Copilot AI review requested due to automatic review settings February 10, 2026 10:40
@hotlong hotlong merged commit 30fa3ec into main Feb 10, 2026
1 of 4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 read this.client.discoveryInfo instead of the non-existent this.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.

Comment on lines +118 to +123
// 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;

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

3 participants