Skip to content

ILM Explain API truncated previous_step_info breaks JSON #135458

@szybia

Description

@szybia

Elasticsearch Version

8.19.1

Installed Plugins

No response

Java Version

bundled

OS Version

linux

Problem Description

When previous_step_info is truncated, it seems it is missing a "} at the end, which breaks JSON parsing.

e.g.

"previous_step_info":{"type":"exception","reason":"<REMOVED>... (28 chars truncated),"phase_execution":

Steps to Reproduce

Not clear, need to investigate further, but assuming you need to cause an exception in an ILM stage, and then when it get's carried over it'll return invalid JSON on subsequent explain calls.

relevant code/links:

  1. Fix ILMHistoryItemTests.testTruncateLongError #125814
  2. public static String truncateWithExplanation(String input) {
    if (input != null && input.length() > MAXIMUM_STEP_INFO_STRING_LENGTH) {
    return Strings.cleanTruncate(input, MAXIMUM_STEP_INFO_STRING_LENGTH)
    + "... ("
    + (input.length() - MAXIMUM_STEP_INFO_STRING_LENGTH)
    + " chars truncated)";
    } else {
    return input;
    }
    }
  3. String truncatedErrorString = LifecycleExecutionState.truncateWithExplanation(fullErrorString);
    if (truncatedErrorString.equals(fullErrorString) == false) {
    // Append a closing quote and closing brace to attempt to make it valid JSON.
    // There is no requirement that it actually be valid JSON, so this is
    // best-effort, but does not cause problems if it is still invalid.
    truncatedErrorString += "\"}";
    }

from a quick glance, my first avenue of investigation would be the other invocation of truncateWithExplanation not having this hack of adding the "}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions