Skip to content

Commit 4bb7516

Browse files
Merge branch 'main' into bkellam/fix_638
2 parents f362595 + 41a6eb4 commit 4bb7516

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Fixed issue where single quotes could not be used in search queries. [#629](https://github.com/sourcebot-dev/sourcebot/pull/629)
1515
- Fixed issue where files with special characters would fail to load. [#636](https://github.com/sourcebot-dev/sourcebot/issues/636)
1616
- Fixed Ask performance issues. [#632](https://github.com/sourcebot-dev/sourcebot/pull/632)
17+
- Fixed regression where creating a new Ask thread when unauthenticated would result in a 404. [#641](https://github.com/sourcebot-dev/sourcebot/pull/641)
1718

1819
## [4.10.0] - 2025-11-24
1920

Dockerfile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# syntax=docker/dockerfile:1
12
# ------ Global scope variables ------
23

34
# Set of global build arguments.
@@ -148,7 +149,7 @@ fi
148149

149150
ENV SKIP_ENV_VALIDATION=0
150151
# ------------------------------
151-
152+
152153
# ------ Runner ------
153154
FROM node-alpine AS runner
154155
# -----------
@@ -220,22 +221,23 @@ COPY --from=zoekt-builder \
220221
/cmd/zoekt-index \
221222
/usr/local/bin/
222223

224+
RUN chown -R sourcebot:sourcebot /app
225+
223226
# Copy zoekt proto files (needed for gRPC client at runtime)
224-
COPY vendor/zoekt/grpc/protos /app/vendor/zoekt/grpc/protos
227+
COPY --chown=sourcebot:sourcebot vendor/zoekt/grpc/protos /app/vendor/zoekt/grpc/protos
225228

226229
# Copy all of the things
227-
COPY --from=web-builder /app/packages/web/public ./packages/web/public
228-
COPY --from=web-builder /app/packages/web/.next/standalone ./
229-
COPY --from=web-builder /app/packages/web/.next/static ./packages/web/.next/static
230+
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/public ./packages/web/public
231+
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/.next/standalone ./
232+
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/.next/static ./packages/web/.next/static
230233

231-
COPY --from=backend-builder /app/node_modules ./node_modules
232-
COPY --from=backend-builder /app/packages/backend ./packages/backend
234+
COPY --chown=sourcebot:sourcebot --from=backend-builder /app/node_modules ./node_modules
235+
COPY --chown=sourcebot:sourcebot --from=backend-builder /app/packages/backend ./packages/backend
233236

234-
COPY --from=shared-libs-builder /app/node_modules ./node_modules
235-
COPY --from=shared-libs-builder /app/packages/db ./packages/db
236-
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
237-
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
238-
COPY --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage
237+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/db ./packages/db
238+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/schemas ./packages/schemas
239+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/shared ./packages/shared
240+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/queryLanguage ./packages/queryLanguage
239241

240242
# Fixes git "dubious ownership" issues when the volume is mounted with different permissions to the container.
241243
RUN git config --global safe.directory "*"
@@ -245,9 +247,6 @@ RUN mkdir -p /run/postgresql && \
245247
chown -R postgres:postgres /run/postgresql && \
246248
chmod 775 /run/postgresql
247249

248-
# Make app directory accessible to both root and sourcebot user
249-
RUN chown -R sourcebot:sourcebot /app
250-
# Make data directory accessible to both root and sourcebot user
251250
RUN chown -R sourcebot:sourcebot /data
252251

253252
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- First, remove the NOT NULL constraint on the createdById column.
2+
ALTER TABLE "Chat" ALTER COLUMN "createdById" DROP NOT NULL;
3+
4+
-- Then, set all chats created by the guest user (id: 1) to have a NULL createdById.
5+
UPDATE "Chat" SET "createdById" = NULL WHERE "createdById" = '1';

packages/db/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ model Chat {
437437
438438
name String?
439439
440-
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade)
441-
createdById String
440+
createdBy User? @relation(fields: [createdById], references: [id], onDelete: Cascade)
441+
createdById String?
442442
443443
createdAt DateTime @default(now())
444444
updatedAt DateTime @updatedAt

packages/web/src/features/chat/actions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use server';
22

33
import { sew } from "@/actions";
4-
import { SOURCEBOT_GUEST_USER_ID } from "@/lib/constants";
54
import { ErrorCode } from "@/lib/errorCodes";
65
import { chatIsReadonly, notFound, ServiceError, serviceErrorResponse } from "@/lib/serviceError";
76
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
@@ -34,13 +33,13 @@ const logger = createLogger('chat-actions');
3433

3534
export const createChat = async () => sew(() =>
3635
withOptionalAuthV2(async ({ org, user, prisma }) => {
37-
const isGuestUser = user?.id === SOURCEBOT_GUEST_USER_ID;
36+
const isGuestUser = user === undefined;
3837

3938
const chat = await prisma.chat.create({
4039
data: {
4140
orgId: org.id,
4241
messages: [] as unknown as Prisma.InputJsonValue,
43-
createdById: user?.id ?? SOURCEBOT_GUEST_USER_ID,
42+
createdById: user?.id,
4443
visibility: isGuestUser ? ChatVisibility.PUBLIC : ChatVisibility.PRIVATE,
4544
},
4645
});

0 commit comments

Comments
 (0)