{"record":{"id":"8172ab756ca7fe93","repo":"apache/hadoop","slug":"error-8172ab","errorCode":null,"errorMessage":" error:\n","messagePattern":" error:\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c","lineNumber":187,"sourceCode":"    }\n    if (i < EXCEPTION_INFO_LEN) {\n        noPrint = (gExceptionInfo[i].noPrintFlag & noPrintFlags);\n        excErrno = gExceptionInfo[i].excErrno;\n    } else {\n        noPrint = 0;\n        excErrno = EINTERNAL;\n    }\n\n    // We don't want to use ExceptionDescribe here, because that requires a\n    // pending exception. Instead, use ExceptionUtils.\n    rootCause = getExceptionUtilString(env, exc, \"getRootCauseMessage\");\n    stackTrace = getExceptionUtilString(env, exc, \"getStackTrace\");\n    // Save the exception details in the thread-local state.\n    setTLSExceptionStrings(rootCause, stackTrace);\n\n    if (!noPrint) {\n        vfprintf(stderr, fmt, ap);\n        fprintf(stderr, \" error:\\n\");\n\n        if (!rootCause) {\n            fprintf(stderr, \"(unable to get root cause for %s)\\n\", className);\n        } else {\n            fprintf(stderr, \"%s\", rootCause);\n        }\n        if (!stackTrace) {\n            fprintf(stderr, \"(unable to get stack trace for %s)\\n\", className);\n        } else {\n            fprintf(stderr, \"%s\", stackTrace);\n        }\n    }\n\n    destroyLocalReference(env, exc);\n    free(className);\n    return excErrno;\n}\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/exception.c#L169-L205","documentation":"This is the banner printExceptionAndFreeV writes right after the caller-supplied context string (e.g. \"hdfsOpenFile(/path): FileSystem#create\") whenever a Java exception from a libhdfs JNI call is being reported. Seeing it means the underlying Hadoop operation genuinely threw; the ExceptionUtils root-cause message and stack trace follow on the next lines, and the function returns an errno mapped from the exception class via gExceptionInfo (FileNotFoundException->ENOENT, AccessControlException->EACCES, SafeModeException->EROFS, QuotaExceededException->EDQUOT, unknown->EINTERNAL).","triggerScenarios":"Any hdfs* API whose internal JNI call throws and whose exception class is not suppressed by the noPrintFlags: hdfsOpenFile on a missing parent directory, hdfsRename without permission, hdfsDelete/hdfsCreate while the NameNode is in safe mode, quota exceeded on write, file already exists, etc.","commonSituations":"Standard companion of every printed libhdfs failure in application stderr and fuse-dfs logs; developers grepping logs find the fragment '<operation> error:' followed by the Java stack trace.","solutions":["Read the lines that follow this banner - they contain the ExceptionUtils root cause and stack trace identifying the actual Hadoop-side failure.","Map the returned errno via the gExceptionInfo table to decide handling (ENOENT missing path, EACCES permissions, EROFS safe mode, EDQUOT quota, EEXIST duplicate, ESTALE lease).","Fix the named Hadoop-side condition (path, permissions, quota, safe mode) rather than changing C-side code.","In fuse-dfs contexts, also check the HDFS audit log for the corresponding denied/failed operation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"hdfsFile f = hdfsOpenFile(fs, path, O_WRONLY | O_CREAT, 0, 0, 0);\nif (!f) {\n    int e = errno;  /* libhdfs already mapped the Java exception class */\n    const char *rc = hdfsGetLastExceptionRootCause();\n    switch (e) {\n    case ENOENT:  /* FileNotFoundException: parent missing */ break;\n    case EACCES:  /* AccessControlException */ break;\n    case EROFS:   /* SafeModeException */ break;\n    case EDQUOT:  /* QuotaExceededException */ break;\n    case EEXIST:  /* FileAlreadyExistsException */ break;\n    default:      /* see stderr banner + stack trace for the rest */ break;\n    }\n}","preventionTips":["Branch on the mapped errno in code; the printed banner and stack trace are for humans.","Capture libhdfs/fuse-dfs stderr to a persistent file so the lines after this banner are never lost.","Pre-check paths with hdfsExists/hdfsGetPathInfo where ENOENT/EEXIST would be common.","Know the mapping table: unknown Java classes come back as EINTERNAL."],"tags":["c","libhdfs","jni","logging","exception","errno-mapping"],"backgroundTag":"hdfs-operation-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}