Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/adapters/hono/src/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,13 @@ export interface ObjectStackHonoOptions {
prefix?: string;
}

/**
* Auth service interface with handleRequest method
*/
interface AuthService {
handleRequest(request: Request): Promise<Response>;
}

/**
* @deprecated Use `HonoServerPlugin` + `createRestApiPlugin()` + `createDispatcherPlugin()` instead.
* This function bundles all routes into a single Hono app using the legacy HttpDispatcher.
Expand DownExpand Up@@ -68,7 +75,7 @@ export function createHonoApp(options: ObjectStackHonoOptions) {
try {
// Try AuthPlugin service first (preferred path)
const authService = typeof options.kernel.getService === 'function'
? options.kernel.getService('auth')
? options.kernel.getService<AuthService>('auth')
: null;

Comment on lines 76 to 80

CopilotAIFeb 10, 2026

Copy link

Choose a reason for hiding this comment

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

ObjectKernel.getService() throws when a service is missing. If the auth plugin/service isn’t registered, getService<AuthService>('auth') will throw and the route will return a 500 from the catch block, never reaching the legacy dispatcher.handleAuth(...) fallback. Wrap the getService call in a try/catch and treat the "service not found" case as null so fallback behavior works.

Copilot uses AI. Check for mistakes.
if (authService && typeof authService.handleRequest === 'function') {
Expand Down
9 changes: 8 additions & 1 deletion packages/adapters/nestjs/src/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,13 @@ export const ConnectReq = createParamDecorator(
},
);

/**
* Auth service interface with handleRequest method
*/
interface AuthService {
handleRequest(request: Request): Promise<Response>;
}

// --- Service ---

@Injectable()
Expand DownExpand Up@@ -109,7 +116,7 @@ export class ObjectStackController {
// Try AuthPlugin service first (preferred path)
const kernel = this.service.getKernel();
const authService = typeof kernel.getService === 'function'
? kernel.getService('auth')
? kernel.getService<AuthService>('auth')
: null;
Comment on lines 117 to 120

CopilotAIFeb 10, 2026

Copy link

Choose a reason for hiding this comment

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

ObjectKernel.getService() throws when a service is missing. If the auth plugin/service isn’t registered, getService<AuthService>('auth') will throw and the handler will return a 500 from the catch block, never reaching the legacy dispatcher.handleAuth(...) fallback. Wrap the getService lookup in a try/catch and treat the "service not found" case as null so the fallback can execute.

Copilot uses AI. Check for mistakes.

if (authService && typeof authService.handleRequest === 'function') {
Expand Down
9 changes: 8 additions & 1 deletion packages/adapters/nextjs/src/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,13 @@ export interface NextAdapterOptions {
prefix?: string;
}

/**
* Auth service interface with handleRequest method
*/
interface AuthService {
handleRequest(request: Request): Promise<Response>;
}

/**
* Creates a route handler for Next.js App Router
* Handles /api/[...objectstack] pattern
Expand DownExpand Up@@ -63,7 +70,7 @@ export function createRouteHandler(options: NextAdapterOptions) {
if (segments[0] === 'auth') {
// Try AuthPlugin service first (preferred path)
const authService = typeof options.kernel.getService === 'function'
? options.kernel.getService('auth')
? options.kernel.getService<AuthService>('auth')
: null;
Comment on lines 71 to 74

CopilotAIFeb 10, 2026

Copy link

Choose a reason for hiding this comment

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

ObjectKernel.getService() throws when a service is missing (it does not return null/undefined). As written, calling getService<AuthService>('auth') will throw when the auth plugin/service isn’t registered, and the code will jump to the outer catch and return a 500, never reaching the legacy dispatcher fallback. Consider wrapping the getService call in a try/catch that treats the specific "service not found" error as a null authService so the fallback path can run.

Copilot uses AI. Check for mistakes.

if (authService && typeof authService.handleRequest === 'function') {
Expand Down
Loading