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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed issue where anonymous access on a Sourcebot instance with a unlimited seat license and anonymous access enabled would result in a "not authenticated" message being displayed. [#866](https://github.com/sourcebot-dev/sourcebot/pull/866)
- Fixed issue where session links generated for a `ask_codebase` mcp call would not be accessible to unauthed users. [#873](https://github.com/sourcebot-dev/sourcebot/pull/873)

## [4.10.28] - 2026-02-07

Expand Down
14 changes: 13 additions & 1 deletion packages/web/src/app/api/(server)/chat/blocking/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const POST = apiHandler(async (request: NextRequest) => {
data: {
orgId: org.id,
createdById: user?.id,
visibility: ChatVisibility.PRIVATE,
visibility: user ? ChatVisibility.PRIVATE : ChatVisibility.PUBLIC,
messages: [] as unknown as Prisma.InputJsonValue,
},
});
Expand Down Expand Up @@ -156,6 +156,18 @@ export const POST = apiHandler(async (request: NextRequest) => {
onFinish: async ({ messages }) => {
finalMessages = messages;
},
onError: (error) => {
if (error instanceof ServiceErrorException) {
throw error;
}

const message = error instanceof Error ? error.message : String(error);
throw new ServiceErrorException({
statusCode: StatusCodes.INTERNAL_SERVER_ERROR,
errorCode: ErrorCode.UNEXPECTED_ERROR,
message,
});
},
})

await Promise.all([
Expand Down
42 changes: 21 additions & 21 deletions packages/web/src/app/api/(server)/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ export const POST = apiHandler(async (req: NextRequest) => {
messages
});
},
onError: (error: unknown) => {
logger.error(error);
Sentry.captureException(error);

if (error == null) {
return 'unknown error';
}

if (typeof error === 'string') {
return error;
}

if (error instanceof Error) {
return error.message;
}

return JSON.stringify(error);
}
});

return createUIMessageStreamResponse({
Expand Down Expand Up @@ -134,6 +152,7 @@ interface CreateMessageStreamResponseProps {
orgId: number;
prisma: PrismaClient;
onFinish: UIMessageStreamOnFinishCallback<SBChatMessage>;
onError: (error: unknown) => string;
}

export const createMessageStream = async ({
Expand All @@ -145,6 +164,7 @@ export const createMessageStream = async ({
orgId,
prisma,
onFinish,
onError,
}: CreateMessageStreamResponseProps) => {
const latestMessage = messages[messages.length - 1];
const sources = latestMessage.parts
Expand Down Expand Up @@ -247,30 +267,10 @@ export const createMessageStream = async ({
type: 'finish',
});
},
onError: errorHandler,
onError,
originalMessages: messages,
onFinish,
});

return stream;
};

const errorHandler = (error: unknown) => {
logger.error(error);
Sentry.captureException(error);

if (error == null) {
return 'unknown error';
}

if (typeof error === 'string') {
return error;
}

if (error instanceof Error) {
return error.message;
}

return JSON.stringify(error);
}