mik-laj commented on a change in pull request #9477:
URL: https://github.com/apache/airflow/pull/9477#discussion_r444542716
##########
File path: airflow/secrets/local_filesystem.py
##########
@@ -84,6 +86,29 @@ def _parse_env_file(file_path: str) -> Tuple[Dict[str,
List[str]], List[FileSynt
return secrets, errors
+def _parse_yaml_file(file_path: str) -> Tuple[Dict[str, List[str]],
List[FileSyntaxError]]:
+ """
+ Parse a file in the YAML format.
+
+ :param file_path: The location of the file that will be processed.
+ :type file_path: str
+ :return: Tuple with mapping of key and list of values and list of syntax
errors
+ """
+ with open(file_path) as f:
+ content = f.read()
+
+ if not content:
+ return {}, [FileSyntaxError(line_no=1, message="The file is empty.")]
+ try:
+ secrets = yaml.safe_load(content)
+ except yaml.YAMLError as e:
Review comment:
```suggestion
except yaml.MarkedYAMLError as e:
return {}, [FileSyntaxError(line_no=e.context_mark.line,
message=str(e))]
except yaml.YAMLError as e:
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]