Skip to content

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

perf: return only on API if no trace found (#6587)

Steffen Schmitz82bf0baab768
diff --git a/web/src/pages/api/public/traces/[traceId].ts b/web/src/pages/api/public/traces/[traceId].ts
index 30ad9007a1..26fbc7b3c2 100644
--- a/web/src/pages/api/public/traces/[traceId].ts
+++ b/web/src/pages/api/public/traces/[traceId].ts
@@ -36,6 +36,13 @@ export default withMiddlewares({
traceId,
projectId: auth.scope.projectId,
});
+
+ if (!trace) {
+ throw new LangfuseNotFoundError(
+ `Trace ${traceId} not found within authorized project`,
+ );
+ }
+
const [observations, scores] = await Promise.all([
getObservationsForTrace(
traceId,
@@ -92,12 +99,6 @@ export default withMiddlewares({
};
});
- if (!trace) {
- throw new LangfuseNotFoundError(
- `Trace ${traceId} not found within authorized project`,
- );
- }
-
const outObservations = observationsView.map(transformDbToApiObservation);
const validatedScores = filterAndValidateDbScoreList({
scores,