You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/01 14:33:40 UTC

[GitHub] [airflow] Narendra-Neerukonda opened a new pull request #17965: sets encoding to utf-8 by default while reading task logs

Narendra-Neerukonda opened a new pull request #17965:
URL: https://github.com/apache/airflow/pull/17965


   related: #16834 
   
   Airflow task log rendering fails when there are characters out of ascii range in the log. Since writing the log doesn't generate this (logs are accessible from backend), the task log reading part needs to be fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk merged pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #17965:
URL: https://github.com/apache/airflow/pull/17965


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #17965:
URL: https://github.com/apache/airflow/pull/17965#issuecomment-911320555


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Narendra-Neerukonda commented on a change in pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
Narendra-Neerukonda commented on a change in pull request #17965:
URL: https://github.com/apache/airflow/pull/17965#discussion_r701211786



##########
File path: airflow/utils/log/file_task_handler.py
##########
@@ -116,7 +116,7 @@ def _read(self, ti, try_number, metadata=None):
 
         if os.path.exists(location):
             try:
-                with open(location) as file:
+                with open(location, encoding="utf-8") as file:

Review comment:
       Makes sense. I feel, we should use 'surrogateescape' as replacement as it will provide the exact bytes that caused the issue, making it more specific for user to debug if they desire to do so.
   And yes, it would definetly be better to have a config to set the encoding.
   I have updated the PR with replacement as surrogate character as of now and created a feature request #17993 and would like to work on this requirement.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] uranusjr commented on a change in pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #17965:
URL: https://github.com/apache/airflow/pull/17965#discussion_r700831719



##########
File path: airflow/utils/log/file_task_handler.py
##########
@@ -116,7 +116,7 @@ def _read(self, ti, try_number, metadata=None):
 
         if os.path.exists(location):
             try:
-                with open(location) as file:
+                with open(location, encoding="utf-8") as file:

Review comment:
       Maybe we should do `error="replace"` or something so a log written in another encoding can still be partially read. I’m suspecting this input-output encoding mismatch only happens on Python 3.7+, when Python starts automatically coerce the default legacy C to UTC-8 ([PEP 538](https://www.python.org/dev/peps/pep-0538/)). If this is the cause, setting `utf-8` here is a correct move, but we should still provide a fallback for weird platforms that need/want to use a platform-specific encoding. Perhaps a new config to explicitly set what encoding to use here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Narendra-Neerukonda commented on a change in pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
Narendra-Neerukonda commented on a change in pull request #17965:
URL: https://github.com/apache/airflow/pull/17965#discussion_r701211786



##########
File path: airflow/utils/log/file_task_handler.py
##########
@@ -116,7 +116,7 @@ def _read(self, ti, try_number, metadata=None):
 
         if os.path.exists(location):
             try:
-                with open(location) as file:
+                with open(location, encoding="utf-8") as file:

Review comment:
       Makes sense. I feel, we should use 'surrogateescape' as replacement as it will provide the exact bytes that caused the issue, making it more specific for user if they desire to do so.
   And yes, it would definetly be better to have a config to set the encoding.
   I have updated the PR with replacement as surrogate character as of now and created a feature request #17993 and would like to work on this requirement.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Narendra-Neerukonda commented on a change in pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
Narendra-Neerukonda commented on a change in pull request #17965:
URL: https://github.com/apache/airflow/pull/17965#discussion_r701211786



##########
File path: airflow/utils/log/file_task_handler.py
##########
@@ -116,7 +116,7 @@ def _read(self, ti, try_number, metadata=None):
 
         if os.path.exists(location):
             try:
-                with open(location) as file:
+                with open(location, encoding="utf-8") as file:

Review comment:
       @uranusjr  Makes sense. I feel, we should use 'surrogateescape' as replacement as it will provide the exact bytes that caused the issue, making it more specific for user to debug if they desire to do so.
   And yes, it would definetly be better to have a config to set the encoding.
   I have updated the PR with replacement as surrogate character as of now and created a feature request #17993 .




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Narendra-Neerukonda commented on a change in pull request #17965: sets encoding to utf-8 by default while reading task logs

Posted by GitBox <gi...@apache.org>.
Narendra-Neerukonda commented on a change in pull request #17965:
URL: https://github.com/apache/airflow/pull/17965#discussion_r701211786



##########
File path: airflow/utils/log/file_task_handler.py
##########
@@ -116,7 +116,7 @@ def _read(self, ti, try_number, metadata=None):
 
         if os.path.exists(location):
             try:
-                with open(location) as file:
+                with open(location, encoding="utf-8") as file:

Review comment:
       @uranusjr  Makes sense. I feel, we should use 'surrogateescape' as replacement as it will provide the exact bytes that caused the issue, making it more specific for user to debug if they desire to do so.
   And yes, it would definetly be better to have a config to set the encoding.
   I have updated the PR with replacement as surrogate character as of now and created a feature request #17993 and would like to work on this requirement.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org