Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION MDC context no longer applied consistently in task/flow logs after…

  1. User

    ISSUE DESCRIPTION

    MDC context no longer applied consistently in task/flow logs after upgrade to v1.0

    Describe the issue

    Hi,

    We recently upgraded from kestra v0.19.5 to v1.0.3 and noticed a change in the logging behavior.

    when using a logback config as such

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration debug="false">
        <include resource="logback/base.xml" />
        <include resource="logback/gcp.xml" />
    
        <root level="WARN">
            <appender-ref ref="CONSOLE_JSON_OUT" />
            <appender-ref ref="CONSOLE_JSON_ERR" />
        </root>
    </configuration>
    

    the additionnal info from the task/flow/execution are not always logged.

    example from a Hello-world flow run:

    {"timestampSeconds":1761224032,"timestampNanos":565000000,"severity":"INFO","thread":"jdbc-execution-executor_0","logger":"execution.gnu_170208","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [execution: 1FLhPmmXgvIghVXzW7hY90] Flow started","context":"default"}
    {"timestampSeconds":1761224032,"timestampNanos":775000000,"severity":"INFO","thread":"worker_0","logger":"task.gnu_170208.hello","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [task: hello] [execution: 1FLhPmmXgvIghVXzW7hY90] [taskrun: 7SKeqte94nC0xUfrgFXHpw] Type Log started","context":"default"}
    {"taskRunId":"7SKeqte94nC0xUfrgFXHpw","tenantId":"main","namespace":"company.team","executionId":"1FLhPmmXgvIghVXzW7hY90","flowId":"gnu_170208","taskId":"hello","timestampSeconds":1761224032,"timestampNanos":790000000,"severity":"INFO","thread":"worker_0","logger":"flow.gnu_170208.hello","message":"Hello World! 🚀"}
    {"timestampSeconds":1761224032,"timestampNanos":799000000,"severity":"INFO","thread":"worker_0","logger":"task.gnu_170208.hello","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [task: hello] [execution: 1FLhPmmXgvIghVXzW7hY90] [taskrun: 7SKeqte94nC0xUfrgFXHpw] Type Log with state SUCCESS completed in 00:00:00.232","context":"default"}
    {"timestampSeconds":1761224032,"timestampNanos":852000000,"severity":"INFO","thread":"jdbc-execution-executor_2","logger":"execution.gnu_170208","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [execution: 1FLhPmmXgvIghVXzW7hY90] Flow completed with state SUCCESS in 00:00:00.405","context":"default"}
    
    

    Only the hello world log itself gets the MDC context.

    It was different in v0.19.5 we relied on this behavior to monitor flow executions.

    I've debug kestra locally and i've been able to add that context by manually setting the contextMap in this method https://github.com/kestra-io/kestra/blob/eb22d3f6ee5b6b92f8a12f03948e7517a02e39cc/core/src/main/java/io/kestra/core/services/LogService.java#L45

    such as :

    public void logExecution(Execution execution, Level level, String message, Object... args) {
        Logger logger = logger(execution);
        MDC.setContextMap(Map.of("tenantId", execution.getTenantId(), "namespace", execution.getNamespace(), "flowId", execution.getFlowId(), "executionId", execution.getId()));
    
        logExecution(execution, logger, level, message, args);
    }
    

    Environment

    • Kestra Version: develop, v1.0

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /kestra, current file: none) bash-$

  2. MiniMax Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. MiniMax Assistant

    Let me look at the LogService.java file mentioned in the issue first.

  4. MiniMax Assistant

    Hmm, the file name in the issue was LogService.java but it's actually ExecutionLogService.java now. Let me look at this file and also searchfor "logExecution".

  5. MiniMax Assistant

    Let me search for the logExecution method in the codebase, since that's the method mentioned in the issue.

  6. MiniMax Assistant

    Now let me look at theLogs.java file:

  7. MiniMax Assistant

    Let me look at the LogEntry class to understand where the structured fields are added.

  8. MiniMax Assistant

    Let me look at the test file for Logs.java:

  9. MiniMax Assistant

    Let me find where the MDC context is set for the structured logger:

  10. MiniMax Assistant

    Let me look at the RunContextLogger.java:

  11. MiniMax Assistant

    Let me search for the old logger name execution.{tenantId} to see where it's used:

  12. MiniMax Assistant

    Let me search specifically for the logger name pattern with "execution."

  13. MiniMax Assistant

    Let me look at the git log to understand recent changes:

  14. MiniMax Assistant

    Let me look at the previous LogService.java version:

  15. MiniMax Assistant

    Let me look at the old v0.19.5 version. Let me see git tags:

  16. MiniMax Assistant

    Now let me look at the current logback config to understand the structured logging:

  17. MiniMax Assistant

    Let me see how MDC is handled in tests too:

  18. MiniMax Assistant

    Let me also look at where these Logs.logExecution methods are called:

  19. MiniMax Assistant

    Let me look at the LogService.java that existed before the change:

  20. MiniMax Assistant

    Now let me see the existing tests and understand what I need to make work:

  21. MiniMax Assistant

    Let me look at FlowId:

  22. MiniMax Assistant

    Let me also look at the TriggerId interface:

  23. MiniMax Assistant

    Now I have enough context to implement the fix. Let me first reproduce the issue with a test script:

  24. MiniMax Assistant

    Now I have a clear understanding. Let me implement the fix:

  25. MiniMax Assistant

    Now let me modify the Logs.java file to set the MDC context:

  26. MiniMax Assistant

    Now let me verify the changes compile by running the tests:

  27. MiniMax Assistant

    The compilation is successful. Now let me run the existing tests for the Logs.java file:

  28. MiniMax Assistant

    There's a test failure because Map.of doesn't allow null values. Let me update the implementation to handle null values:

  29. MiniMax Assistant

    Let me update the implementation to handle null values:

  30. MiniMax Assistant

    Now let me run the tests again to confirm:

  31. MiniMax Assistant

    All 4 tests pass. Now let me write a test script to verify the MDC context is set correctly:

  32. MiniMax Assistant

    Let me create a temporary test to verify the MDC behavior:

  33. MiniMax Assistant

    All 7 tests pass. Now let me delete the temporary test file since it's not part of the actual fix:

  34. MiniMax Assistant

    Let me also run the LogsTest to make sure existing tests still pass:

  35. MiniMax Assistant

    Let me look at the final implementation:

  36. MiniMax Assistant

    Let me also check that there aren't other places in the codebase that may need updating:

  37. MiniMax Assistant

    Let me run a broader test to make sure I haven't broken anything else:

  38. MiniMax Assistant

    Let me find out which test is failing:

  39. MiniMax Assistant

    Let me look at the failing test to verify it's unrelated to my changes:

  40. MiniMax Assistant

    This test is clearly unrelated to my fix - it's testing files with non-ASCII characters. Let me confirm by checking out the original Logs.java and running this test:

  41. MiniMax Assistant

    The test was already failing before my changes - it's unrelated. Let me restore my changes:

  42. MiniMax Assistant

    Good. Now let me make sure my changes are still inplace:

  43. MiniMax Assistant

    Let me run the LogsTest again to confirm:

  44. MiniMax Assistant

    Let me check the diff of my changes:

  45. MiniMax Assistant

    Let me check if there are any other places that reference the Logger field of the LogService or Logs class:

  46. MiniMax Assistant

    Let me look at the WorkerTaskProcessor to ensure the fix works:

  47. MiniMax Assistant

    Now let me run a broader set of tests related to the executor to make sure I haven't broken anything:

  48. MiniMax Assistant

    Let me also run the webserver tests:

  49. MiniMax Assistant

    Let me focus on tests that are most likely to be affected by my change:

  50. MiniMax Assistant

    Let me also check the related tests to make sure things work:

  51. MiniMax Assistant

    Let me look at the final implementation once more to make sure it's correct:

  52. MiniMax Assistant

    Let me look at the diff of my changes:

  53. MiniMax Assistant

    Let me check the build for the entire core module:

  54. MiniMax Assistant

    Let me look at the diff once more and think about the issue again:

  55. MiniMax Assistant

    Let me also check the executor tests pass:

  56. MiniMax Assistant

    All 52 tests pass. Let me also verify the workertests:

  57. MiniMax Assistant

    Let me make sure everything is in order. Let me look at the final Logs.java one more time:

  58. MiniMax Assistant

    Let me also check the WorkerTriggerProcessor and other places where logs are called:

  59. MiniMax Assistant

    All these places use one of the Logs methods I've already updated. So my fix should cover them all.

    Let me also look at one more place toverify - the executor service:

  60. MiniMax Assistant

    These calls are the ones that produce the log lines mentioned in the issue (like "Flow started" and "Flow completed with state SUCCESS"). My fix should handle these correctly.

    Let me also verify the trigger andtask run logs:

  61. MiniMax Assistant

    Good. These calls are also covered by my fix.

    Now let me think about whether I should also check the WorkerTriggerProcessor and WorkerTaskProcessor to see if they pass a logger:

  62. MiniMax Assistant

    Let me verify my understanding by reading the relevant parts:

  63. MiniMax Assistant

    Let me run all the tests for the affected modules once more to confirm everything works:

  64. MiniMax Assistant

    All 4 existing tests pass. Let me also run the executor tests:

  65. MiniMax Assistant

    There are no ExecutorServiceTest in the executor module. Letme look for executor tests:

  66. MiniMax Assistant

    Let me also check the diff once more:

  67. MiniMax Assistant

    Let me do a final verification by checking how my fix interacts with the StackdriverJsonLayout:

  68. MiniMax Assistant

    I'm satisfied with the fix. Let me do a final check to ensure everything compiles:

  69. MiniMax Assistant

    Let me make sure all tests pass:

  70. MiniMax Assistant

    Let me check the final diff one more time:

  71. MiniMax Assistant

    Let me make a final check on the implementation and verify that everything is in order:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.