{"record":{"id":"8ed31fc82c7ac83a","repo":"nodejs/node","slug":"dictionary-s-is-larger-than-maximum-allowed-d","errorCode":null,"errorMessage":"dictionary [%s] is larger than maximum allowed: %d\\n","messagePattern":"dictionary \\[(.+?)\\] is larger than maximum allowed: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":909,"sourceCode":"\n  if (context->dictionary_path == NULL) return BROTLI_TRUE;\n  f = fopen(context->dictionary_path, \"rb\");\n  if (f == NULL) {\n    fprintf(stderr, \"failed to open dictionary file [%s]: %s\\n\",\n            PrintablePath(context->dictionary_path), strerror(errno));\n    return BROTLI_FALSE;\n  }\n\n  file_size_64 = FileSize(context->dictionary_path);\n  if (file_size_64 == -1) {\n    fprintf(stderr, \"could not get size of dictionary file [%s]\",\n            PrintablePath(context->dictionary_path));\n    fclose(f);\n    return BROTLI_FALSE;\n  }\n\n  if (file_size_64 > kMaxDictionarySize) {\n    fprintf(stderr, \"dictionary [%s] is larger than maximum allowed: %d\\n\",\n            PrintablePath(context->dictionary_path), kMaxDictionarySize);\n    fclose(f);\n    return BROTLI_FALSE;\n  }\n  context->dictionary_size = (size_t)file_size_64;\n\n  buffer = (uint8_t*)malloc(context->dictionary_size);\n  if (!buffer) {\n    fprintf(stderr, \"could not read dictionary: out of memory\\n\");\n    fclose(f);\n    return BROTLI_FALSE;\n  }\n  bytes_read = fread(buffer, sizeof(uint8_t), context->dictionary_size, f);\n  if (bytes_read != context->dictionary_size) {\n    free(buffer);\n    fprintf(stderr, \"failed to read dictionary [%s]: %s\\n\",\n            PrintablePath(context->dictionary_path), strerror(errno));\n    fclose(f);","sourceCodeStart":891,"sourceCodeEnd":927,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L891-L927","documentation":"The dictionary file size exceeds `kMaxDictionarySize`, which is `BROTLI_MAX_DISTANCE - BROTLI_MAX_BACKWARD_LIMIT(24)` (approximately 16 MiB minus 16 MiB = implementation-dependent; effectively the raw dictionary must fit within the encoder's maximum backward distance window). The message prints the offending path and the maximum allowed size in bytes.","triggerScenarios":"Supplying a dictionary file larger than the brotli encoder's maximum raw dictionary size. The limit is a compile-time constant derived from brotli's distance-coding parameters, not a user-configurable value.","commonSituations":"Using a large pre-trained dictionary for domain-specific compression (e.g. a web text corpus) that exceeds the limit; accidentally pointing `--dictionary` at a large data file instead of the intended small dictionary.","solutions":["Trim or retrain the dictionary to be at most `kMaxDictionarySize` bytes.","Verify you are pointing at the correct dictionary file, not a large data file.","Check the value of `BROTLI_MAX_DISTANCE` and `BROTLI_MAX_BACKWARD_LIMIT(24)` in the build's headers to know the exact limit."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#include <sys/stat.h>\n#include <stdint.h>\n#include <stdbool.h>\n\n// BROTLI_MAX_DISTANCE is typically 0x3FFFFFFF (16 MiB window).\n// The effective raw dict limit is implementation-dependent.\n// Use a conservative 16 MiB ceiling for pre-validation:\n#define SAFE_MAX_DICT (16 * 1024 * 1024)\n\nbool dictionary_within_limit(const char *path) {\n    struct stat st;\n    if (stat(path, &st) != 0) return false;\n    return (int64_t)st.st_size <= SAFE_MAX_DICT;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check dictionary file size before passing it to brotli.","Trim or retrain large dictionaries to stay under the limit.","Print the exact limit from the error message and adjust your dictionary accordingly."],"tags":["dictionary","compression","size-limit","brotli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}