Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(api): return 404 instead of 501 for v2 APIs on self-hosted (#12610)

Steffen Schmitz5732087d588f
diff --git a/web/src/pages/api/public/v2/metrics.ts b/web/src/pages/api/public/v2/metrics.ts
index 8e5b6f8d3b..54e20d0ca3 100644
--- a/web/src/pages/api/public/v2/metrics.ts
+++ b/web/src/pages/api/public/v2/metrics.ts
@@ -6,7 +6,7 @@ import {
GetMetricsV2Query,
GetMetricsV2Response,
} from "@/src/features/public-api/types/metrics";
-import { InvalidRequestError, NotImplementedError } from "@langfuse/shared";
+import { InvalidRequestError, LangfuseNotFoundError } from "@langfuse/shared";
import {
executeQuery,
validateQuery,
@@ -22,7 +22,7 @@ export default withMiddlewares({
responseSchema: GetMetricsV2Response,
fn: async ({ query, auth }) => {
if (env.LANGFUSE_ENABLE_EVENTS_TABLE_V2_APIS !== "true") {
- throw new NotImplementedError(
+ throw new LangfuseNotFoundError(
"v2 APIs are currently in beta and only available on Langfuse Cloud",
);
}
diff --git a/web/src/pages/api/public/v2/observations/index.ts b/web/src/pages/api/public/v2/observations/index.ts
index a35fa7aed9..4fb5bf8bd4 100644
--- a/web/src/pages/api/public/v2/observations/index.ts
+++ b/web/src/pages/api/public/v2/observations/index.ts
@@ -1,5 +1,5 @@
import { getObservationsV2FromEventsTableForPublicApi } from "@langfuse/shared/src/server";
-import { NotImplementedError } from "@langfuse/shared";
+import { LangfuseNotFoundError } from "@langfuse/shared";
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
@@ -18,7 +18,7 @@ export default withMiddlewares({
responseSchema: GetObservationsV2Response,
fn: async ({ query, auth }) => {
if (env.LANGFUSE_ENABLE_EVENTS_TABLE_V2_APIS !== "true") {
- throw new NotImplementedError(
+ throw new LangfuseNotFoundError(
"v2 APIs are currently in beta and only available on Langfuse Cloud",
);
}