{"record":{"id":"4ea3cc8917457db0","repo":"bazelbuild/bazel","slug":"prefix-msg-n","errorCode":null,"errorMessage":"prefix msg \"\\n\"","messagePattern":"prefix msg \"\\\\n\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/tools/singlejar/diag.h","lineNumber":41,"sourceCode":"    defined(__OpenBSD__)\n\n#include <err.h>\n#define diag_err(...) err(__VA_ARGS__)\n#define diag_errx(...) errx(__VA_ARGS__)\n#define diag_warn(...) warn(__VA_ARGS__)\n#define diag_warnx(...) warnx(__VA_ARGS__)\n\n#elif defined(_WIN32)\n\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#include <stdio.h>\n#include <string.h>\n#include <windows.h>\n#define _diag_msg(prefix, msg, ...)                  \\\n  {                                                  \\\n    fprintf(stderr, prefix msg \"\\n\", ##__VA_ARGS__); \\\n  }\n#define _diag_msgx(exit_value, prefix, msg, ...) \\\n  {                                              \\\n    _diag_msg(prefix, msg, ##__VA_ARGS__);       \\\n    ::ExitProcess(exit_value);                   \\\n  }\n#define diag_err(exit_value, fmt, ...) \\\n  _diag_msgx(exit_value, \"ERROR: \", fmt, ##__VA_ARGS__)\n#define diag_errx(exit_value, fmt, ...) \\\n  _diag_msgx(exit_value, \"ERROR: \", fmt, ##__VA_ARGS__)\n#define diag_warn(fmt, ...) _diag_msg(\"WARNING: \", fmt, ##__VA_ARGS__)\n#define diag_warnx(fmt, ...) _diag_msg(\"WARNING: \", fmt, ##__VA_ARGS__)\n\n#else\n#error Unknown platform\n#endif\n\n#endif  // BAZEL_SRC_TOOLS_SINGLEJAR_DIAG_H_","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/tools/singlejar/diag.h#L23-L59","documentation":"On Windows, singlejar's diag.h implements its diagnostics (diag_err, diag_errx, diag_warn, diag_warnx) as macros that fprintf 'prefix + msg + newline' to stderr; the _diag_msgx variants then call ::ExitProcess(exit_value), terminating the zip creation tool immediately. The message template here is the shared body that stamps 'ERROR: ' or 'WARNING: ' in front of every singlejar diagnostic on Windows.","triggerScenarios":"Calling singlejar (via Bazel's java_singlejar or proto bundling actions) on Windows when zip entry insertion fails, output file cannot be written, entry names collide, or the output zip already exists read-only; each failure path formats its message through _diag_msg before ExitProcess for the err variants.","commonSituations":"Output .jar marked read-only or locked by another process (VS, antivirus); path length beyond MAX_PATH; duplicate entry names when merging jars; disk full on the output drive during a Windows build.","solutions":["Check whether the output jar named in the preceding message is locked/read-only; close editors and rerun.","Rerun the failing action with --subcommands to capture the exact singlejar invocation and run it manually to see the full diagnostic.","Shorten output paths (enable Windows long-path support or move the workspace closer to the drive root).","Verify free disk space on the output volume.","If entries are reported duplicated, check the srcs of the java_singlejar/proto rule for the same file listed twice."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before singlejar runs, clear Windows file-lock obstacles on the output\n// (pseudo) if exists(output) { clear_readonly(output); fail if locked }\nstd::error_code ec;\nauto st = std::filesystem::status(out_path, ec);\nif (!ec && exists(st)) {\n  std::filesystem::permissions(out_path, std::filesystem::perms::owner_write, std::filesystem::perm_options::add, ec);\n  if (ec) return error(\"output not writable: \" + out_path.string());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Exclude bazel-out from antivirus real-time scanning on Windows build agents.","Do not keep generated jars open in editors while rebuilding.","Deduplicate srcs in java_singlejar rules so entry-collision errors cannot fire.","Watch free disk space; singlejar diagnostics often follow ENOSPC."],"tags":["c-preprocessor","windows","singlejar","zip","logging","fatal-exit"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}