<@ULVA73B9P> Is there a way to propagate the full ...
# ask-marvin
k
@Marvin Is there a way to propagate the full stack trace from a failing subflow to the parent's logs?
m
To propagate the full stack trace from a failing subflow to the parent's logs in Prefect, it seems the system's behavior might slightly differ between Prefect 2.x and 3.x based on the information available. Handling subflows can inherently be tricky; they are treated within parent flows somewhat like individual tasks, with their state mirrored in the parent flow. Here are a few highlights from the searches: 1. Prefect 2.x: Subflows create a task run in the parent flow, which mirrors the state of the child flow. This relationship is tracked through identifiers like
child_flow_run_id
and
parent_task_run_id
. While there's no explicit documentation about logging full stack traces from subflows to parents in Prefect 2.x, you might attempt to include error handling in your subflow, using a logging strategy to capture the stack trace and propagate it manually to the parent flow logs. More about subflows in Prefect 2.x can be found here: Prefect Flows. 2. Prefect 3.x: It's noted from issues and the documentation that Prefect automatically logs the tracebacks of any errors that arise during execution, which could inherently include subflow errors if captured correctly. You might want to ensure that exceptions are allowed to propagate up. Custom logging could be used to enhance what is logged from a subflow, perhaps through Prefect's logger functions. For more on logging with Prefect 3.x, check out Prefect Logging. 3. GitHub Issues: There are some related issues where users faced challenges with subflows incorrectly reporting their state or having specific logging issues. One specific issue suggests a bug where the state might not reflect correctly in every instance, which could be a factor if you're experiencing inconsistent behavior. For more details, see the GitHub issue on Flows with subflows reporting state. If you're trying to achieve consistent logging behavior, you might consider reviewing your flow's exception handling or the logging configuration to ensure that exceptions can propagate as needed and that custom log messages are properly configured. And as it happens, concocting some unique logging strategies might add a bit of flair, just like programming with a touch of poetry. If you have any more questions or if there's something else you'd like to explore, feel free to ask!