languagetool-org/languagetool · error · RuntimeException

IOException while writing debug tags

Error message

IOException while writing debug tags

What it means

The debug_tagged_write step in CompoundDebugLogger writes POSTag analysis of Ukrainian compounds to a debug file; an IOException there is rethrown as a RuntimeException with this message. The real cause (e.g. closed stream or disk error) is in the wrapped exception.

Source

Thrown at languagetool-language-modules/uk/src/main/java/org/languagetool/tagging/uk/CompoundDebugLogger.java:119

        
        String lemma = analyzedToken.getLemma();

        if (! prevLemma.equals(lemma)) {
          if( prevLemma.length() > 0 ) {
            writer.append(", ");
          }
          writer.append(lemma); //.append(' ');
          prevLemma = lemma;
          firstTag = true;
        }

        writer.append(firstTag ? " " : "|").append(analyzedToken.getPOSTag());
        firstTag = false;
      }
      writer.newLine();
      if( ++cnt % 10 == 0) writer.flush();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

  public void logGenderMix(String word, boolean leftNv, String leftPosTag, String rightPosTag) {
    if( compoundGenderMixDebugWriter != null ) {
      try {
        compoundGenderMixDebugWriter.append(word + " " + (leftNv ? rightPosTag : leftPosTag));
        compoundGenderMixDebugWriter.newLine();
        compoundGenderMixDebugWriter.flush();
      } catch (IOException e) {
        System.err.println("Failed to write into gender mix file");
      }
    }
  }

}

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Verify the debug file's directory is writable and has free space
  2. Keep the debug writer open for the lifetime of the tagging session
  3. Check the cause IOException in the stacktrace for the underlying error
  4. Turn off compound debug logging in production
Defensive patterns

Strategy: try-catch

Validate before calling

if (Files.getFileSystem(debugDir).getReadOnlyStores().size() == 0
        && Files.getFileStore(debugDir).getTotalSpace() > 0) { /* ok */ }

Try / catch

try {
    compoundLogger.logTaggedCompound(word, tokens);
} catch (RuntimeException e) {
    Throwable c = e.getCause();
    if (c instanceof IOException) { LOGGER.warn("debug tags write failed", c); }
    else throw e;
}

Prevention

When it happens

Trigger: logTaggedCompound -> debug_tagged_write when the debug BufferedWriter cannot flush or append: file removed, permissions changed, stream closed, or disk full after every 10th write triggers flush().

Common situations: Long-running Ukrainian tagging sessions where the debug log file was deleted by tmp cleaners, or CI containers with a full /tmp volume.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/4d3d970471c85c85. Report an issue: GitHub.