Skip to content

Commit acdf06d

Browse files
jsonbaileyclaude
andcommitted
chore: Note credential-leak risk on raw error logging in examples
JS-side reviewer flagged that provider error responses may include credentials (OpenAI has historically echoed API keys back in error JSON). The examples intentionally print the raw exception so users can see what's wrong without modifying code, but a short comment above each top-level catch-and-log explains that production code should sanitize errors first. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 44e98bc commit acdf06d

7 files changed

Lines changed: 24 additions & 0 deletions

File tree

features/create_agent/create_agent_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ async def async_main():
109109
else:
110110
print("\nNo judge evaluations were performed.")
111111

112+
# For convenience during example debugging, we print the raw error. In
113+
# production, sanitize errors before logging — provider responses may
114+
# include credentials or other sensitive data.
112115
except Exception as err:
113116
print("Error:", err)
114117
finally:

features/create_agent_graph/create_agent_graph_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ async def async_main():
127127
print(f" score: {eval_result.score}")
128128
print(f" reasoning: {eval_result.reasoning}")
129129

130+
# For convenience during example debugging, we print the raw error. In
131+
# production, sanitize errors before logging — provider responses may
132+
# include credentials or other sensitive data.
130133
except Exception as err:
131134
print("Error:", err)
132135
finally:

features/create_judge/create_judge_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ async def async_main():
9494
print(f" reasoning: {judge_result.reasoning}")
9595

9696
print("\nDone!")
97+
# For convenience during example debugging, we print the raw error. In
98+
# production, sanitize errors before logging — provider responses may
99+
# include credentials or other sensitive data.
97100
except Exception as err:
98101
print("Error:", err)
99102
finally:

features/create_model/create_model_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ async def async_main():
9595
else:
9696
print("\nNo judge evaluations were performed. Try adding a judge to the AI config to see results.")
9797

98+
# For convenience during example debugging, we print the raw error. In
99+
# production, sanitize errors before logging — provider responses may
100+
# include credentials or other sensitive data.
98101
except Exception as err:
99102
print("Error:", err)
100103
finally:

getting_started/langchain/invoke/langchain_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ async def async_main():
118118
if summary.tool_calls:
119119
print(f" Tool calls: {', '.join(summary.tool_calls)}")
120120

121+
# For convenience during example debugging, we print the raw error. In
122+
# production, sanitize errors before logging — provider responses may
123+
# include credentials or other sensitive data.
121124
except Exception as e:
122125
print(f"Error during completion: {e}")
123126
print("Please ensure you have the correct API keys and credentials set up for the detected provider.")

getting_started/langgraph/react_agent/langgraph_agent_example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ def main():
121121
if summary.tool_calls:
122122
print(f" Tool calls: {', '.join(summary.tool_calls)}")
123123

124+
# For convenience during example debugging, we print the raw error. In
125+
# production, sanitize errors before logging — provider responses may
126+
# include credentials or other sensitive data.
124127
except Exception as e:
125128
print(f"\nError: {e}")
126129
print("Please ensure you have the correct API keys and credentials set up for the detected providers.")

getting_started/langgraph/state_graph/langgraph_multi_agent_example.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def ai_node(
147147
}
148148
)
149149

150+
# For convenience during example debugging, we print the raw error. In
151+
# production, sanitize errors before logging — provider responses may
152+
# include credentials or other sensitive data.
150153
except Exception as e:
151154
print(f"Error in node for {config_key}: {e}")
152155
return Command(
@@ -278,6 +281,9 @@ def calculate_average(numbers):
278281
print(final_report)
279282
print("="*80)
280283

284+
# For convenience during example debugging, we print the raw error. In
285+
# production, sanitize errors before logging — provider responses may
286+
# include credentials or other sensitive data.
281287
except Exception as e:
282288
print(f"Error during workflow execution: {e}")
283289
print("Please ensure you have the correct API keys and credentials set up for the detected providers.")

0 commit comments

Comments
 (0)