zpl_toolchain_diagnostics 0.1.10

Diagnostic codes and structured error reporting for the ZPL toolchain
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
{
  // Diagnostic codes spec — machine-readable catalog of all ZPL toolchain diagnostics.
  // Each entry declares the context keys that its structured `context` field may carry.
  "version": "1.1.0",
  "diagnostics": [
    {
      "id": "ZPL1101",
      "constName": "ARITY",
      "severity": "error",
      "category": "arity",
      "summary": "Too many arguments",
      "description": "Too many arguments provided compared to the command's arity.",
      "contextKeys": ["command", "arity", "actual"]
    },
    {
      "id": "ZPL1103",
      "constName": "INVALID_ENUM",
      "severity": "error",
      "category": "value-validation",
      "summary": "Invalid enumerated value",
      "description": "Argument value is not one of the allowed enumerated values.",
      "contextKeys": ["command", "arg", "value"]
    },
    {
      "id": "ZPL1104",
      "constName": "EMPTY_FIELD_DATA",
      "severity": "error",
      "category": "value-validation",
      "summary": "Empty field data",
      "description": "Field data (^FD/^FV) is present but empty; often unintended.",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL1105",
      "constName": "STRING_TOO_SHORT",
      "severity": "error",
      "category": "value-validation",
      "summary": "String too short",
      "description": "String is shorter than the minimum length allowed.",
      "contextKeys": ["command", "arg", "value", "min_length", "actual_length"]
    },
    {
      "id": "ZPL1106",
      "constName": "STRING_TOO_LONG",
      "severity": "error",
      "category": "value-validation",
      "summary": "String too long",
      "description": "String exceeds the maximum length allowed.",
      "contextKeys": ["command", "arg", "value", "max_length", "actual_length"]
    },
    {
      "id": "ZPL1107",
      "constName": "EXPECTED_INTEGER",
      "severity": "error",
      "category": "value-validation",
      "summary": "Expected integer",
      "description": "Argument expected an integer value but received a non-integer string.",
      "contextKeys": ["command", "arg", "value"]
    },
    {
      "id": "ZPL1108",
      "constName": "EXPECTED_NUMERIC",
      "severity": "error",
      "category": "value-validation",
      "summary": "Expected numeric",
      "description": "Argument expected a numeric value but received a non-numeric string.",
      "contextKeys": ["command", "arg", "value"]
    },
    {
      "id": "ZPL1109",
      "constName": "EXPECTED_CHAR",
      "severity": "error",
      "category": "value-validation",
      "summary": "Expected single character",
      "description": "Argument expected a single character but received a multi-character or empty string.",
      "contextKeys": ["command", "arg", "value"]
    },
    {
      "id": "ZPL1201",
      "constName": "OUT_OF_RANGE",
      "severity": "error",
      "category": "range",
      "summary": "Value outside range",
      "description": "Value is outside the allowed numeric range for this argument.",
      "contextKeys": ["command", "arg", "value", "min", "max"]
    },
    {
      "id": "ZPL1202",
      "constName": "ROUNDING_VIOLATION",
      "severity": "warn",
      "category": "rounding",
      "summary": "Rounding policy violation",
      "description": "Value does not conform to the rounding policy (e.g., not a multiple).",
      "contextKeys": ["command", "arg", "value", "multiple", "epsilon"],
      "messageTemplates": {
        "notMultiple": "{command}.{arg}={value} not a multiple of {multiple}"
      }
    },
    {
      "id": "ZPL1401",
      "constName": "PROFILE_CONSTRAINT",
      "severity": "error",
      "category": "profile-constraints",
      "summary": "Profile constraint violation",
      "description": "Value violates a profile constraint (e.g., exceeds page width).",
      "contextKeys": ["command", "arg", "field", "op", "limit", "actual"]
    },
    {
      "id": "ZPL1402",
      "constName": "PRINTER_GATE",
      "severity": "error",
      "category": "profile-constraints",
      "summary": "Printer gate violation",
      "description": "A command, argument, or enum value requires a printer capability (gate) that is not declared in the loaded profile. Check the profile's feature set or choose a different command/value supported by your printer.",
      "contextKeys": ["command", "gate", "level", "profile", "arg", "value"]
    },
    {
      "id": "ZPL1403",
      "constName": "MEDIA_MODE_UNSUPPORTED",
      "severity": "warn",
      "category": "profile-constraints",
      "summary": "Media mode unsupported",
      "description": "A command selects a media mode, tracking method, or print type that is not listed in the loaded profile's media capabilities.",
      "contextKeys": ["command", "kind", "value", "supported", "profile_method", "profile"]
    },
    {
      "id": "ZPL1501",
      "constName": "REQUIRED_MISSING",
      "severity": "error",
      "category": "presence",
      "summary": "Required argument missing",
      "description": "A required argument is missing or unset.",
      "contextKeys": ["command", "arg"]
    },
    {
      "id": "ZPL1502",
      "constName": "REQUIRED_EMPTY",
      "severity": "warn",
      "category": "presence",
      "summary": "Empty required value",
      "description": "An argument is empty but required to have a value.",
      "contextKeys": ["command", "arg"]
    },
    {
      "id": "ZPL2101",
      "constName": "REQUIRED_COMMAND",
      "severity": "warn",
      "category": "cross-command-constraints",
      "summary": "Required command missing",
      "description": "A required command was not found in the label where expected.",
      "contextKeys": ["command", "target", "kind", "scope"]
    },
    {
      "id": "ZPL2102",
      "constName": "INCOMPATIBLE_COMMAND",
      "severity": "warn",
      "category": "cross-command-constraints",
      "summary": "Incompatible commands",
      "description": "This command is incompatible with another present in the label.",
      "contextKeys": ["command", "target", "kind", "scope"]
    },
    {
      "id": "ZPL2103",
      "constName": "ORDER_BEFORE",
      "severity": "warn",
      "category": "cross-command-constraints",
      "summary": "Ordering violation (before)",
      "description": "Command ordering rule violated: this command should appear before the referenced one.",
      "contextKeys": ["command", "target", "kind", "scope"]
    },
    {
      "id": "ZPL2104",
      "constName": "ORDER_AFTER",
      "severity": "warn",
      "category": "cross-command-constraints",
      "summary": "Ordering violation (after)",
      "description": "Command ordering rule violated: this command should appear after the referenced one.",
      "contextKeys": ["command", "target", "kind", "scope"]
    },
    {
      "id": "ZPL2201",
      "constName": "FIELD_DATA_WITHOUT_ORIGIN",
      "severity": "warn",
      "category": "structural-validation",
      "summary": "Field data without origin",
      "description": "Field data command (^FD/^FV) without a preceding field origin (^FO/^FT).",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL2202",
      "constName": "EMPTY_LABEL",
      "severity": "info",
      "category": "structural-validation",
      "summary": "Empty label",
      "description": "Empty label with no commands between ^XA and ^XZ.",
      "contextKeys": []
    },
    {
      "id": "ZPL2203",
      "constName": "FIELD_NOT_CLOSED",
      "severity": "warn",
      "category": "structural-validation",
      "summary": "Field origin before previous closed",
      "description": "Field origin (^FO/^FT) opens a new field before the previous field was closed with ^FS.",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL2204",
      "constName": "ORPHANED_FIELD_SEPARATOR",
      "severity": "warn",
      "category": "structural-validation",
      "summary": "Field separator without origin",
      "description": "Field separator (^FS) without a preceding field origin (^FO/^FT).",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL2205",
      "constName": "HOST_COMMAND_IN_LABEL",
      "severity": "warn",
      "category": "structural-validation",
      "summary": "Host command in label",
      "description": "Host or device command appearing inside a label (between ^XA and ^XZ).",
      "contextKeys": ["command", "plane"]
    },
    {
      "id": "ZPL2301",
      "constName": "DUPLICATE_FIELD_NUMBER",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Duplicate field number",
      "description": "Duplicate field number (^FN) — same number used multiple times in a label.",
      "contextKeys": ["command", "field_number"]
    },
    {
      "id": "ZPL2302",
      "constName": "POSITION_OUT_OF_BOUNDS",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Position exceeds dimensions",
      "description": "Field position (^FO/^FT) exceeds label dimensions set by ^PW/^LL or profile.",
      "contextKeys": ["command", "axis", "value", "limit"]
    },
    {
      "id": "ZPL2303",
      "constName": "UNKNOWN_FONT",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Font not loaded",
      "description": "Font referenced by ^A is not a built-in font (A-Z, 0-9) and has not been loaded via ^CW.",
      "contextKeys": ["command", "font"]
    },
    {
      "id": "ZPL2304",
      "constName": "INVALID_HEX_ESCAPE",
      "severity": "error",
      "category": "semantic-validation",
      "summary": "Invalid hex escape sequence",
      "description": "Invalid hex escape sequence in field data when ^FH is active. Indicator character defaults to '_' but can be changed via ^FH argument.",
      "contextKeys": ["command", "indicator"]
    },
    {
      "id": "ZPL2305",
      "constName": "REDUNDANT_STATE",
      "severity": "info",
      "category": "semantic-validation",
      "summary": "State override unused",
      "description": "State-setting command overrides a previous one without any consumer using the earlier value.",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL2306",
      "constName": "SERIALIZATION_WITHOUT_FIELD_NUMBER",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Serialization without field number",
      "description": "Serialization command (^SN/^SF) used in a field without a ^FN field number assignment.",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL2307",
      "constName": "GF_DATA_LENGTH_MISMATCH",
      "severity": "error",
      "category": "semantic-validation",
      "summary": "Graphic data length mismatch",
      "description": "^GF graphic data length does not match declared binary_byte_count for the given compression format.",
      "contextKeys": ["command", "format", "declared", "actual", "expected"]
    },
    {
      "id": "ZPL2308",
      "constName": "GF_BOUNDS_OVERFLOW",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Graphic field exceeds label bounds",
      "description": "The ^GF graphic at the current ^FO position would extend beyond the effective label dimensions. This may cause truncated or misaligned output.",
      "contextKeys": ["command", "x", "y", "graphic_width", "graphic_height", "label_width", "label_height"]
    },
    {
      "id": "ZPL2309",
      "constName": "GF_MEMORY_EXCEEDED",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Graphic memory usage exceeds available RAM",
      "description": "Total graphic field data in this label exceeds the printer's available RAM. This may cause print failures or data loss.",
      "contextKeys": ["command", "total_bytes", "ram_bytes"]
    },
    {
      "id": "ZPL2310",
      "constName": "MISSING_EXPLICIT_DIMENSIONS",
      "severity": "info",
      "category": "semantic-validation",
      "summary": "Missing explicit label dimensions",
      "description": "Label uses profile-provided dimensions but does not contain explicit ^PW or ^LL commands. Adding explicit dimension commands makes the label self-contained and portable across printers.",
      "contextKeys": ["missing_commands"]
    },
    {
      "id": "ZPL2311",
      "constName": "OBJECT_BOUNDS_OVERFLOW",
      "severity": "warn",
      "category": "semantic-validation",
      "summary": "Text or barcode extends beyond label bounds",
      "description": "A text field or barcode at the current ^FO/^FT position would extend beyond the effective label dimensions. Content may be clipped or misaligned on print.",
      "contextKeys": [
        "object_type",
        "x",
        "y",
        "estimated_width",
        "estimated_height",
        "label_width",
        "label_height",
        "overflow_x",
        "overflow_y",
        "overflow_x_ratio",
        "overflow_y_ratio",
        "confidence",
        "audience"
      ],
      "objectBoundsPolicy": {
        "lowConfidenceMaxOverflowDots": 24.0,
        "lowConfidenceMaxOverflowRatio": 0.05,
        "lowConfidenceSeverity": "info"
      },
      "messageTemplates": {
        "lowConfidence": "{object_type} at ({x}, {y}) may extend beyond label bounds ({label_width}×{label_height} dots, estimated)",
        "highConfidence": "{object_type} at ({x}, {y}) extends beyond label bounds ({label_width}×{label_height} dots)"
      }
    },
    {
      "id": "ZPL2401",
      "constName": "BARCODE_INVALID_CHAR",
      "severity": "error",
      "category": "barcode-validation",
      "summary": "Invalid barcode data character",
      "description": "Field data contains characters not allowed by the active barcode's character set.",
      "contextKeys": ["command", "character", "position", "allowedSet"],
      "messageTemplates": {
        "invalidChar": "invalid character '{character}' at position {position} in {command} field data (allowed: [{allowedSet}])"
      }
    },
    {
      "id": "ZPL2402",
      "constName": "BARCODE_DATA_LENGTH",
      "severity": "warn",
      "category": "barcode-validation",
      "summary": "Barcode data length violation",
      "description": "Field data length violates the active barcode's length requirements.",
      "contextKeys": ["command", "actual", "expected", "min", "max", "parity", "actualParity"],
      "messageTemplates": {
        "allowedLengths": "{command} field data length {actual} (expected one of [{expected}])",
        "exactLength": "{command} field data length {actual} (expected exactly {expected})",
        "minLength": "{command} field data too short: {actual} chars (minimum {min})",
        "maxLength": "{command} field data too long: {actual} chars (maximum {max})",
        "parity": "{command} field data length {actual} should be {parity} (got {actualParity})"
      }
    },
    {
      "id": "ZPL3001",
      "constName": "NOTE",
      "severity": "info",
      "category": "notes",
      "summary": "Informational note",
      "description": "Informational note about command usage or behavior.",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL.PARSER.0001",
      "constName": "PARSER_NO_LABELS",
      "severity": "info",
      "category": "parser",
      "summary": "No labels detected",
      "description": "No labels detected in the input.",
      "contextKeys": []
    },
    {
      "id": "ZPL.PARSER.1001",
      "constName": "PARSER_INVALID_COMMAND",
      "severity": "error",
      "category": "parser",
      "summary": "Invalid or missing command code",
      "description": "Invalid or missing command code after leader (^ or ~), spacing violation between opcode and arguments based on signature spacing policy semantics, or reserved raw command leaders encountered in free-form command text (e.g., ^FX comments).",
      "contextKeys": ["command", "spacing"]
    },
    {
      "id": "ZPL.PARSER.1002",
      "constName": "PARSER_UNKNOWN_COMMAND",
      "severity": "warn",
      "category": "parser",
      "summary": "Unknown command code",
      "description": "Unknown command code (not in the command spec tables).",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL.PARSER.1102",
      "constName": "PARSER_MISSING_TERMINATOR",
      "severity": "error",
      "category": "parser",
      "summary": "Missing label terminator",
      "description": "Missing label terminator (^XZ).",
      "contextKeys": ["expected"]
    },
    {
      "id": "ZPL.PARSER.1202",
      "constName": "PARSER_MISSING_FIELD_SEPARATOR",
      "severity": "error",
      "category": "parser",
      "summary": "Missing field separator",
      "description": "Missing field separator (^FS) before label end or end of input.",
      "contextKeys": ["expected", "command"]
    },
    {
      "id": "ZPL.PARSER.1203",
      "constName": "PARSER_FIELD_DATA_INTERRUPTED",
      "severity": "warn",
      "category": "parser",
      "summary": "Field data interrupted",
      "description": "Field data interrupted by another command before ^FS.",
      "contextKeys": ["command"]
    },
    {
      "id": "ZPL.PARSER.1301",
      "constName": "PARSER_STRAY_CONTENT",
      "severity": "warn",
      "category": "parser",
      "summary": "Stray content",
      "description": "Stray content (text or punctuation) found outside of a command context.",
      "contextKeys": []
    },
    {
      "id": "ZPL.PARSER.1302",
      "constName": "PARSER_NON_ASCII_ARG",
      "severity": "error",
      "category": "parser",
      "summary": "Non-ASCII argument",
      "description": "Prefix/delimiter change commands (^CC, ^CT, ^CD) require an ASCII character argument. Non-ASCII characters cannot be used as command prefixes or delimiters because the lexer operates on single bytes.",
      "contextKeys": ["command"]
    }
  ]
}