Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/python/src/index.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 OTEL env filtering not applied consistently across all methods

The OTEL env var filtering was applied to runScript (line 93-97) and runInline (line 158-163), but not to run (line 32) or any of the stream.* methods (stream.run at line 213, stream.runScript at line 260, stream.runInline at line 305). All of these still use ...process.env directly. If the intent is to "prevent stderr flood" from parent OTEL vars leaking into Python subprocesses, the same issue presumably exists for all execution paths. This inconsistency may be intentional (perhaps only script-based methods are affected), but it's worth confirming.

(Refers to line 32)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,19 @@ export const python = {
nodeOptions: {
...(options.nodeOptions || {}),
env: {
...process.env,
// Filter out parent OTEL vars to prevent stderr flood
...Object.fromEntries(
Object.entries(process.env).filter(
([key]) => !key.startswith("OTEL_")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 key.startswith is not a function — should be key.startsWith (capital W)

JavaScript's String.prototype method is startsWith (camelCase with capital W), not startswith (all lowercase, which is the Python convention). Calling key.startswith("OTEL_") will throw a TypeError: key.startswith is not a function at runtime, crashing python.runScript() every time it is called. This affects line 95 in runScript and line 161 in runInline.

Suggested change
([key]) => !key.startswith("OTEL_")
([key]) => !key.startsWith("OTEL_")
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

)
),
...options.env,
TRACEPARENT: carrier["traceparent"],
OTEL_RESOURCE_ATTRIBUTES: `${
SemanticInternalAttributes.EXECUTION_ENVIRONMENT
}=trigger,${Object.entries(taskContext.attributes)
.map(([key, value]) => `${key}=${value}`)
.join(",")}`,
OTEL_LOG_LEVEL: "DEBUG",
},
},
throwOnError: false,
Expand Down Expand Up @@ -151,7 +155,12 @@ export const python = {
nodeOptions: {
...(options.nodeOptions || {}),
env: {
...process.env,
// Filter out parent OTEL vars to prevent stderr flood
...Object.fromEntries(
Object.entries(process.env).filter(
([key]) => !key.startswith("OTEL_")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 key.startswith is not a function in runInline — should be key.startsWith

Same bug as in runScript: key.startswith("OTEL_") at packages/python/src/index.ts:161 uses the Python naming convention instead of JavaScript's startsWith. This will throw a TypeError at runtime, crashing python.runInline() on every invocation.

Suggested change
([key]) => !key.startswith("OTEL_")
([key]) => !key.startsWith("OTEL_")
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

)
),
...options.env,
TRACEPARENT: carrier["traceparent"],
OTEL_RESOURCE_ATTRIBUTES: `${
Expand Down