Error Messages¶
4ward produces actionable, specific error messages for every P4Runtime operation. Every error tells you what went wrong, shows the value you sent, and lists the valid options.
Examples¶
Unknown table ID:
Wrong action for a table:
INVALID_ARGUMENT: unknown action ID 99999 in table 'port_table'
(valid actions: 'MyIngress.forward' (29683729),
'MyIngress.drop' (25652968), 'NoAction' (21257015))
Match field type mismatch:
Table full:
@refers_to violation:
Constraint violation (with source location from @entry_restriction):
INVALID_ARGUMENT: All entries must satisfy:
In @entry_restriction of table 'MyIngress.acl'; at offset line 2, columns 9 to 58:
|
2 | ipv4_dst::mask != 0 -> ether_type::value == 0x0800;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
But your entry does not.
Simulator error (with P4 source location):
Design principles¶
- What, not just that. Every error includes the entity name, the value that caused the problem, and the constraint that was violated.
- How to fix it. "Unknown" errors list valid options with their numeric IDs. Enum errors list valid values.
- Where in the P4 source. Simulator errors include the P4 file, line, and column from the IR source info.
- Proper gRPC status codes.
NOT_FOUNDfor missing entities,INVALID_ARGUMENTfor malformed requests,RESOURCE_EXHAUSTEDfor capacity limits,FAILED_PRECONDITIONfor state requirements,PERMISSION_DENIEDfor arbitration,UNIMPLEMENTEDfor unsupported features. - Structured error details. Batch writes include per-update status with
spaceandcodefields per P4Runtime spec section 12.3. - Golden-tested. All 75 error paths are locked down by golden tests. Messages cannot silently degrade. Update with:
All error messages¶
See grpc/golden_errors/
for the complete list of golden-tested error messages.