Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix(onboarding): correct empty step 3 database config UI (#1520)

Yuzhong Zhang26ed0ff2381b
diff --git a/src/Dockerfile b/src/Dockerfile
index 4da317a8..dd6ca16d 100644
--- a/src/Dockerfile
+++ b/src/Dockerfile
@@ -94,8 +94,10 @@ ARG TARGETPLATFORM
ENV OPAMP_SUPERVISOR_VERSION=${OPAMP_SUPERVISOR_VERSION}
ENV TARGETARCH=${TARGETARCH}
-# Install only the additional runtime dependencies needed
-RUN apt-get update && apt-get install -y --no-install-recommends \
+# Install only the additional runtime dependencies needed.
+# bullseye-security InRelease Valid-Until can expire in CI while the mirror is
+# otherwise healthy; skip the timestamp check so apt-get update still works.
+RUN apt-get update -o Acquire::Check-Valid-Until=false && apt-get install -y --no-install-recommends \
bash \
openssl \
ca-certificates \
@@ -130,7 +132,7 @@ COPY --from=otel-downloader /tmp/otelcol-contrib /app/opamp/otelcontribcol
COPY --from=otel-downloader /tmp/opampsupervisor /app/opamp/opampsupervisor
# Verify binary architectures match runtime
-RUN apt-get update && apt-get install -y --no-install-recommends file && \
+RUN apt-get update -o Acquire::Check-Valid-Until=false && apt-get install -y --no-install-recommends file && \
echo "Verifying binary architectures..." && \
echo "Runtime architecture: $(uname -m)" && \
echo "otelcontribcol:" && file /app/opamp/otelcontribcol && \
diff --git a/src/client/src/__tests__/app/onboarding-page.test.tsx b/src/client/src/__tests__/app/onboarding-page.test.tsx
new file mode 100644
index 00000000..e7e5a74a
--- /dev/null
+++ b/src/client/src/__tests__/app/onboarding-page.test.tsx
@@ -0,0 +1,119 @@
+/**
+ * @jest-environment jsdom
+ */
+
+const fetchOrganisationList = jest.fn().mockResolvedValue(undefined);
+const fetchPendingInvitations = jest.fn().mockResolvedValue(undefined);
+const fetchProjectList = jest.fn().mockResolvedValue([]);
+const fetchDatabaseConfigList = jest.fn().mockResolvedValue(undefined);
+
+jest.mock("next-auth/react", () => ({
+ useSession: () => ({ update: jest.fn() }),
+}));
+
+jest.mock("posthog-js/react", () => ({
+ usePostHog: () => ({ capture: jest.fn(), group: jest.fn() }),
+}));
+
+jest.mock("next/link", () => ({
+ __esModule: true,
+ default: ({ href, children }: { href: string; children: React.ReactNode }) => (
+ <a href={href}>{children}</a>
+ ),
+}));
+
+jest.mock("@/helpers/client/organisation", () => ({
+ fetchOrganisationList: (...args: unknown[]) => fetchOrganisationList(...args),
+ fetchPendingInvitations: (...args: unknown[]) => fetchPendingInvitations(...args),
+ acceptInvitation: jest.fn(),
+ declineInvitation: jest.fn(),
+}));
+
+jest.mock("@/helpers/client/project", () => ({
+ fetchProjectList: (...args: unknown[]) => fetchProjectList(...args),
+}));
+
+jest.mock("@/helpers/client/database-config", () => ({
+ fetchDatabaseConfigList: (...args: unknown[]) => fetchDatabaseConfigList(...args),
+ deleteDatabaseConfig: jest.fn(),
+}));
+
+jest.mock("@/store", () => ({
+ useRootStore: jest.fn(),
+}));
+
+import { fireEvent, render, screen } from "@testing-library/react";
+import OnboardingPage from "@/app/(playground)/onboarding/page";
+import { useRootStore } from "@/store";
+
+const org = { id: "org-1", name: "My cool org", isCurrent: true, memberCount: 1 };
+const project = {
+ id: "proj-1",
+ organisationId: "org-1",
+ name: "Default Project",
+ slug: "default",
+ isDefault: true,
+ isCurrent: true,
+ createdAt: "2026-01-01T00:00:00.000Z",
+};
+
+function mockStore({
+ databaseConfigs = [] as unknown[],
+}: { databaseConfigs?: unknown[] } = {}) {
+ const state = {
+ organisation: {
+ pendingInvitations: [],
+ list: [org],
+ current: org,
+ isLoading: false,
+ },
+ project: {
+ list: [project],
+ current: project,
+ currentEnvironment: "production",
+ isLoading: false,
+ },
+ databaseConfig: {
+ list: databaseConfigs,
+ isLoading: false,
+ },
+ };
+ (useRootStore as unknown as jest.Mock).mockImplementation((selector) =>
+ selector(state)
+ );
+}
+
+describe("OnboardingPage database config step", () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ mockStore();
+ global.fetch = jest.fn().mockResolvedValue({
+ ok: true,
+ json: async () => ({ environments: [] }),
+ }) as unknown as typeof fetch;
+ });
+
+ it("renders an Add database config control on step 3 instead of a dead connectors link", () => {
+ render(<OnboardingPage />);
+
+ expect(
+ screen.getByRole("button", { name: "Add database config" })
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText("You have not created any database config")
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole("link", { name: /Add New Config/i })
+ ).not.toBeInTheDocument();
+ });
+
+ it("opens the ClickHouse config form from step 3", () => {
+ render(<OnboardingPage />);
+
+ fireEvent.click(screen.getByRole("button", { name: "Add database config" }));
+
+ expect(screen.getByText("Add ClickHouse connector")).toBeInTheDocument();
+ expect(screen.getByPlaceholderText("127.0.0.1")).toBeInTheDocument();
+ expect(screen.getByPlaceholderText("8123")).toBeInTheDocument();
+ });
+});
diff --git a/src/client/src/__tests__/constants/route.test.ts b/src/client/src/__tests__/constants/route.test.ts
index 54ba175c..42b6c55c 100644
--- a/src/client/src/__tests__/constants/route.test.ts
+++ b/src/client/src/__tests__/constants/route.test.ts
@@ -74,10 +74,22 @@ describe('ONBOARDING_WHITELIST_API_ROUTES', () => {
expect(ONBOARDING_WHITELIST_API_ROUTES.exact.POST).toContain('/api/organisation');
});
+ it('allows database config setup APIs before onboarding is complete', () => {
+ expect(ONBOARDING_WHITELIST_API_ROUTES.exact.GET).toContain('/api/db-config');
+ expect(ONBOARDING_WHITELIST_API_ROUTES.exact.GET).toContain('/api/project/environment');
+ expect(ONBOARDING_WHITELIST_API_ROUTES.exact.POST).toContain('/api/db-config');
+ expect(ONBOARDING_WHITELIST_API_ROUTES.exact.POST).toContain('/api/clickhouse');
+ expect(ONBOARDING_WHITELIST_API_ROUTES.exact.POST).toContain('/api/project/environment');
+ });
+
it('prefix.POST includes /api/organisation/current/', () => {
expect(ONBOARDING_WHITELIST_API_ROUTES.prefix.POST).toContain('/api/organisation/current/');
});
+ it('prefix.POST includes /api/db-config/ for setting the active config', () => {
+ expect(ONBOARDING_WHITELIST_API_ROUTES.prefix.POST).toContain('/api/db-config/');
+ });
+
it('prefix.DELETE includes /api/organisation/invitation/', () => {
expect(ONBOARDING_WHITELIST_API_ROUTES.prefix.DELETE).toContain('/api/organisation/invitation/');
});
diff --git a/src/client/src/__tests__/middleware/check-auth.test.ts b/src/client/src/__tests__/middleware/check-auth.test.ts
index dbfba20b..4504c568 100644
--- a/src/client/src/__tests__/middleware/check-auth.test.ts
+++ b/src/client/src/__tests__/middleware/check-auth.test.ts
@@ -385,6 +385,38 @@ describe('checkAuth', () => {
await middleware(req as any, makeFetchEvent());
expect(NextResponse.next).toHaveBeenCalled();
});
+
+ it('allows GET to /api/db-config without onboarding so step 3 can list ClickHouse configs', async () => {
+ (getToken as jest.Mock).mockResolvedValue({ hasCompletedOnboarding: false });
+ const req = makeRequest('GET', '/api/db-config');
+ await middleware(req as any, makeFetchEvent());
+ expect(NextResponse.next).toHaveBeenCalled();
+ expect(NextResponse.json).not.toHaveBeenCalled();
+ });
+
+ it('allows POST to /api/db-config without onboarding so step 3 can save ClickHouse configs', async () => {
+ (getToken as jest.Mock).mockResolvedValue({ hasCompletedOnboarding: false });
+ const req = makeRequest('POST', '/api/db-config');
+ await middleware(req as any, makeFetchEvent());
+ expect(NextResponse.next).toHaveBeenCalled();
+ expect(NextResponse.json).not.toHaveBeenCalled();
+ });
+
+ it('allows GET to /api/project/environment without onboarding', async () => {
+ (getToken as jest.Mock).mockResolvedValue({ hasCompletedOnboarding: false });
+ const req = makeRequest('GET', '/api/project/environment');
+ await middleware(req as any, makeFetchEvent());
+ expect(NextResponse.next).toHaveBeenCalled();
+ expect(NextResponse.json).not.toHaveBeenCalled();
+ });
+
+ it('allows POST to /api/clickhouse without onboarding so the db config form can ping', async () => {
+ (getToken as jest.Mock).mockResolvedValue({ hasCompletedOnboarding: false });
+ const req = makeRequest('POST', '/api/clickhouse');
+ await middleware(req as any, makeFetchEvent());
+ expect(NextResponse.next).toHaveBeenCalled();
+ expect(NextResponse.json).not.toHaveBeenCalled();
+ });
});
describe('onboarding-whitelisted API routes (prefix match)', () => {
@@ -410,6 +442,14 @@ describe('checkAuth', () => {
await middleware(req as any, makeFetchEvent());
expect(NextResponse.next).toHaveBeenCalled();
});
+
+ it('allows POST to /api/db-config/current/:id without onboarding', async () => {
+ (getToken as jest.Mock).mockResolvedValue({ hasCompletedOnboarding: false });
+ const req = makeRequest('POST', '/api/db-config/current/db-1');
+ await middleware(req as any, makeFetchEvent());
+ expect(NextResponse.next).toHaveBeenCalled();
+ expect(NextResponse.json).not.toHaveBeenCalled();
+ });
});
describe('withAuth callbacks.authorized', () => {
diff --git a/src/client/src/app/(playground)/onboarding/page.tsx b/src/client/src/app/(playground)/onboarding/page.tsx
index 0229673a..1d56bead 100644
--- a/src/client/src/app/(playground)/onboarding/page.tsx
+++ b/src/client/src/app/(playground)/onboarding/page.tsx
@@ -38,6 +38,10 @@ import {
getProjectIsLoading,
getProjectList,
} from "@/selectors/project";
+import {
+ getDatabaseConfigList,
+ getDatabaseConfigListIsLoading,
+} from "@/selectors/database-config";
import {
acceptInvitation,
declineInvitation,
@@ -45,6 +49,7 @@ import {
fetchPendingInvitations,
} from "@/helpers/client/organisation";
import { fetchProjectList } from "@/helpers/client/project";
+import { fetchDatabaseConfigList } from "@/helpers/client/database-config";
import { postData } from "@/utils/api";
import asaw from "@/utils/asaw";
import getMessage from "@/constants/messages";
@@ -53,6 +58,7 @@ import Link from "next/link";
import Loader from "@/components/common/loader";
import FeaturePageHeader from "@/components/(playground)/feature-page-header";
import ProjectEnvironmentSwitcher from "@/components/(playground)/organisation/project-environment-switcher";
+import DatabaseConfigPage from "@/components/(playground)/database-config/database-config-page";
function TimelineStep({
active,
@@ -150,9 +156,10 @@ export default function OnboardingPage() {
const projects = useRootStore(getProjectList);
const currentProject = useRootStore(getCurrentProject);
const isProjectLoading = useRootStore(getProjectIsLoading);
- const [connectorLoading, setConnectorLoading] = useState(false);
- const [hasDbConfig, setHasDbConfig] = useState(false);
+ const databaseConfigs = useRootStore(getDatabaseConfigList);
+ const isDatabaseConfigLoading = useRootStore(getDatabaseConfigListIsLoading);
const hasProject = Boolean(currentProject?.id && (projects?.length || 0) > 0);
+ const hasDbConfig = Boolean(databaseConfigs?.length);
const isSetupComplete = Boolean(currentOrg?.id && hasProject && hasDbConfig);
const isInitialising =
!currentOrg?.id &&
@@ -180,12 +187,7 @@ export default function OnboardingPage() {
useEffect(() => {
if (currentProject?.id) {
- setConnectorLoading(true);
- fetch("/api/connectors")
- .then((response) => response.ok ? response.json() : { connectors: [] })
- .then((body) => setHasDbConfig((body.connectors || []).some((connector: { type?: string }) => connector.type === "clickhouse")))
- .catch(() => setHasDbConfig(false))
- .finally(() => setConnectorLoading(false));
+ fetchDatabaseConfigList(() => {});
}
}, [currentProject?.id]);
@@ -405,14 +407,11 @@ export default function OnboardingPage() {
title={messages.HOME_SETUP_DB_CONFIG_STEP}
>
{hasProject && !hasDbConfig && currentProject?.id ? (
- <Button asChild size="sm" className="h-9">
- <Link href={`/organisation/project/${currentProject.id}/connectors`}>
- <Database className="mr-1.5 h-3.5 w-3.5" />
- {connectorLoading
- ? messages.LOADING
- : messages.ADD_NEW_CONFIG}
- </Link>
- </Button>
+ isDatabaseConfigLoading && databaseConfigs === undefined ? (
+ <p className="text-sm text-muted-foreground">{messages.LOADING}</p>
+ ) : (
+ <DatabaseConfigPage hideHeader />
+ )
) : null}
</TimelineStep>
<TimelineStep
diff --git a/src/client/src/constants/route.ts b/src/client/src/constants/route.ts
index 064946b3..1302c003 100644
--- a/src/client/src/constants/route.ts
+++ b/src/client/src/constants/route.ts
@@ -51,15 +51,34 @@ export const ONBOARDING_WHITELIST_ROUTE_PREFIXES = [
// Prefix entries must include a trailing slash to avoid overmatching sibling routes.
export const ONBOARDING_WHITELIST_API_ROUTES = {
exact: {
- GET: ["/api/organisation", "/api/organisation/invitation", "/api/user/profile", "/api/auth/session"],
- POST: ["/api/organisation", "/api/user/complete-onboarding", "/api/auth/session"],
+ GET: [
+ "/api/organisation",
+ "/api/organisation/invitation",
+ "/api/user/profile",
+ "/api/auth/session",
+ "/api/db-config",
+ "/api/project/environment",
+ ],
+ POST: [
+ "/api/organisation",
+ "/api/user/complete-onboarding",
+ "/api/auth/session",
+ "/api/db-config",
+ "/api/clickhouse",
+ "/api/project/environment",
+ ],
},
prefix: {
- GET: ["/api/organisation/"],
- POST: ["/api/organisation/current/", "/api/organisation/invitation/", "/api/organisation/"],
- PUT: ["/api/organisation/"],
+ GET: ["/api/organisation/", "/api/db-config/"],
+ POST: [
+ "/api/organisation/current/",
+ "/api/organisation/invitation/",
+ "/api/organisation/",
+ "/api/db-config/",
+ ],
+ PUT: ["/api/organisation/", "/api/db-config/"],
PATCH: ["/api/organisation/"],
- DELETE: ["/api/organisation/invitation/", "/api/organisation/"],
+ DELETE: ["/api/organisation/invitation/", "/api/organisation/", "/api/db-config/"],
},
} as const;