-
Notifications
You must be signed in to change notification settings - Fork 62
All special characters in jobs/pods logs #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the handling of special characters in Kubernetes pod and job logs by preserving non-ASCII characters like French accented letters (é, è, à, etc.) that were previously being stripped out. The change addresses an issue where the existing ASCII-only encoding was too restrictive and caused message truncation for internationalized content.
- Replaces direct ASCII encoding with a try-catch approach to preserve Unicode characters
- Adds fallback to ASCII encoding only when the primary logging fails
- Applies the fix consistently across both pod log reading and job waiting functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| contents/pods-read-logs.py | Updates log output handling to preserve Unicode characters with ASCII fallback |
| contents/job-wait.py | Applies the same Unicode-preserving log handling for job monitoring |
Comments suppressed due to low confidence (2)
contents/pods-read-logs.py:38
- The original code used print() but the new code uses log.info(). This changes the output destination and may break existing functionality that depends on stdout output.
try:
contents/pods-read-logs.py:50
- The original code used print() but the new code uses log.info(). This changes the output destination and may break existing functionality that depends on stdout output.
try:
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| print(line.encode('ascii', 'ignore')) | ||
| try: | ||
| log.info(line) | ||
| except: |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a bare except clause is not recommended as it catches all exceptions, including system exits and keyboard interrupts. Consider catching specific exceptions like UnicodeError or UnicodeEncodeError instead.
| except: | |
| except UnicodeError: |
| print(line.encode('ascii', 'ignore')) | ||
| try: | ||
| log.info(line) | ||
| except: |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a bare except clause is not recommended as it catches all exceptions, including system exits and keyboard interrupts. Consider catching specific exceptions like UnicodeError or UnicodeEncodeError instead.
| except: | |
| except UnicodeError: |
| log.info(line.encode('ascii', 'ignore')) | ||
| try: | ||
| log.info(line) | ||
| except: |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a bare except clause is not recommended as it catches all exceptions, including system exits and keyboard interrupts. Consider catching specific exceptions like UnicodeError or UnicodeEncodeError instead.
| except: | |
| except UnicodeEncodeError: |
Hi,
I have an issue with special characters disappearing from Kubernetes logs.
I noticed issue #122, which removes all non-ASCII characters, but this also filters out characters like é, è, à, etc., which causes my French messages to be truncated.
I would like to replace:
with:
I added the try/except as a fallback, but I believe it may not be necessary since log.info(line) already works fine.
Would this change be acceptable?
Here are some screenshots
logs output :

Job :

Wait-for :

Characters used : ✅ ! # $ % & ' ( )éèàùüêûîô * + , - . / ; < = > ? @ [ \ ] ^ _ ` { | } ~µ🧙
Thanks!