Skip to content

Commit 2848c7f

Browse files
jsonbaileyclaude
andcommitted
chore: Shorten and reposition error-logging caveat comment
The three-line caveat above each top-level catch-and-log is now a single line directly above the print call, which keeps the security note tied to the actual logging statement rather than to the except clause. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent acdf06d commit 2848c7f

7 files changed

Lines changed: 8 additions & 24 deletions

File tree

features/create_agent/create_agent_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ 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.
115112
except Exception as err:
113+
# In production, sanitize before logging — provider errors may include credentials.
116114
print("Error:", err)
117115
finally:
118116
# Flush pending events and close the client.

features/create_agent_graph/create_agent_graph_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,8 @@ 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.
133130
except Exception as err:
131+
# In production, sanitize before logging — provider errors may include credentials.
134132
print("Error:", err)
135133
finally:
136134
# Flush pending events and close the client.

features/create_judge/create_judge_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ 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.
10097
except Exception as err:
98+
# In production, sanitize before logging — provider errors may include credentials.
10199
print("Error:", err)
102100
finally:
103101
# Flush pending events and close the client.

features/create_model/create_model_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ 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.
10198
except Exception as err:
99+
# In production, sanitize before logging — provider errors may include credentials.
102100
print("Error:", err)
103101
finally:
104102
# Flush pending events and close the client.

getting_started/langchain/invoke/langchain_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ 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.
124121
except Exception as e:
122+
# In production, sanitize before logging — provider errors may include credentials.
125123
print(f"Error during completion: {e}")
126124
print("Please ensure you have the correct API keys and credentials set up for the detected provider.")
127125

getting_started/langgraph/react_agent/langgraph_agent_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ 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.
127124
except Exception as e:
125+
# In production, sanitize before logging — provider errors may include credentials.
128126
print(f"\nError: {e}")
129127
print("Please ensure you have the correct API keys and credentials set up for the detected providers.")
130128

getting_started/langgraph/state_graph/langgraph_multi_agent_example.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ 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.
153150
except Exception as e:
151+
# In production, sanitize before logging — provider errors may include credentials.
154152
print(f"Error in node for {config_key}: {e}")
155153
return Command(
156154
goto=END,
@@ -281,10 +279,8 @@ def calculate_average(numbers):
281279
print(final_report)
282280
print("="*80)
283281

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.
287282
except Exception as e:
283+
# In production, sanitize before logging — provider errors may include credentials.
288284
print(f"Error during workflow execution: {e}")
289285
print("Please ensure you have the correct API keys and credentials set up for the detected providers.")
290286

0 commit comments

Comments
 (0)