Skip to content

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

fix: accept non-lowercased environments instead of rejecting (#9999)

Steffen Schmitz766ba3d8f5f2
diff --git a/packages/shared/src/server/ingestion/types.ts b/packages/shared/src/server/ingestion/types.ts
index 6dcd931840..7249fe29a0 100644
--- a/packages/shared/src/server/ingestion/types.ts
+++ b/packages/shared/src/server/ingestion/types.ts
@@ -202,6 +202,7 @@ const ENVIRONMENT_NAME_REGEX_ERROR_MESSAGE =
const PublicEnvironmentName = z
.string()
+ .toLowerCase()
.max(40, "Maximum length is 40 characters")
.regex(/^(?!langfuse)[a-z0-9-_]+$/, ENVIRONMENT_NAME_REGEX_ERROR_MESSAGE)
.default("default");
diff --git a/web/src/__tests__/async/otel-api.servertest.ts b/web/src/__tests__/async/otel-api.servertest.ts
index f5f15684cf..ed6971e9e9 100644
--- a/web/src/__tests__/async/otel-api.servertest.ts
+++ b/web/src/__tests__/async/otel-api.servertest.ts
@@ -224,4 +224,82 @@ describe("/api/public/otel/v1/traces API Endpoint", () => {
expect(response.status).toBe(200);
});
+
+ it("should transform deployment.environment to lowercase", async () => {
+ const traceId = randomBytes(16);
+ const spanId = randomBytes(8);
+
+ const payload = {
+ resourceSpans: [
+ {
+ resource: {
+ attributes: [
+ {
+ key: "deployment.environment",
+ value: { stringValue: "Production" },
+ },
+ ],
+ },
+ scopeSpans: [
+ {
+ scope: {
+ name: "langfuse-sdk",
+ version: "2.60.3",
+ attributes: [
+ {
+ key: "public_key",
+ value: { stringValue: "pk-lf-1234567890" },
+ },
+ ],
+ },
+ spans: [
+ {
+ traceId: {
+ type: "Buffer",
+ data: traceId,
+ },
+ spanId: {
+ type: "Buffer",
+ data: spanId,
+ },
+ name: "test-span",
+ kind: 1,
+ startTimeUnixNano: {
+ low: 466848096,
+ high: 406528574,
+ unsigned: true,
+ },
+ endTimeUnixNano: {
+ low: 467248096,
+ high: 406528574,
+ unsigned: true,
+ },
+ attributes: [],
+ status: {},
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+
+ const response = await makeAPICall(
+ "POST",
+ "/api/public/otel/v1/traces",
+ payload,
+ );
+
+ expect(response.status).toBe(200);
+
+ await waitForExpect(async () => {
+ const trace = await getTraceById({
+ projectId,
+ traceId: traceId.toString("hex"),
+ });
+ expect(trace).toBeDefined();
+ expect(trace!.id).toBe(traceId.toString("hex"));
+ expect(trace!.environment).toBe("production");
+ }, 25_000);
+ }, 30_000);
});