YANG deviation statement: how devices document departures from a standard module

300-435 By islever Editorial Last updated

Short answer

A A YANG deviation statement records where a device's implementation departs from a published module via deviate not-supported, add, replace or delete, not error handling, version control or module import.

Question

What is YANG 'deviation' statement?
  1. Documents device implementation differences from standard YANG Correct Answer
  2. Error handling
  3. Version control
  4. Module import

Key Takeaways

A YANG deviation statement lets a device declare where its implementation departs from a published module, using deviate not-supported, add, replace or delete inside a separate deviation module that leaves the base module untouched. Option A captures that purpose, while error handling, version history and dependencies belong to error-message/error-app-tag, revision and import statements. Because the standard file is never edited, the deviation modules advertised in NETCONF hello capabilities and the YANG library deviations list are what let a client derive the effective schema before sending a payload.

Expert Analysis

A published YANG module is only a contract sketch until the device discloses which parts it actually honours, and the deviation statement is the standard hook for that disclosure — exactly the "device implementation differences" that option A names.

RFC 7950 defines deviation as a schema-level exception for a published module

In YANG 1.1, deviation is a top-level statement whose single argument is an absolute-schema-nodeid pointing at a node defined in another module. Its body must carry at least one deviate substatement, and the four permitted arguments map to distinct remedies: not-supported removes the node from the device's effective schema, add attaches properties such as a must constraint or a unique tag, replace swaps an existing property value for a different one, and delete strips a property that an earlier deviation introduced. The base module text is never edited, so every other implementation compiling the same file stays interoperable; the divergence lives in a separate file, conventionally named with a -deviation suffix and shipped with the device image. A NETCONF server lists those files among its hello capabilities, and the YANG library model (RFC 8525) exposes them through its deviations leaf-list. Tooling such as pyang can resolve base plus deviation into one effective schema when both files are supplied. That architecture — a device-authored module stating how its real implementation departs from the standard one — is the substance of option A, and nothing in the statement's grammar or lifecycle touches error signalling, revision history or imports.

Device-declared deviation is the only YANG mechanism that records a shortfall against a mandated node

All four choices are YANG terms with settled meanings, so the decision turns on definition rather than on context. Suppose a platform cannot evaluate the must expression guarding a leaf, or cannot store a mandatory leaf the standard module requires. The vendor has no legitimate way to delete that leaf from the published file, because customers, competing vendors and third-party tooling all compile the same file. The only compliant escape is a deviation module that names the node and marks it not-supported or relaxes the offending property; a client that ignores the deviation and pushes the leaf is rejected by the device. Option B lands on a different construct entirely: error handling in YANG lives in error-message and error-app-tag inside must or when, and on the wire in NETCONF rpc-error elements. Option C describes revision and yang-version, which track a module's editorial history, not a device's fidelity to it. Option D describes import, which merely makes definitions from another module referenceable through a prefix and an optional revision-date.

The boundary between deviation and if-feature separates after-the-fact exceptions from designed optionality

These two mechanisms are routinely merged in study material, yet they act at opposite ends of a model's life. A feature is authored into the module before any device ships: the vendor writes feature foo and gates nodes with if-feature foo, and each platform advertises the features it supports, so a client computes a legal payload without the module changing at all. Deviation is what remains when the contract was already frozen and a platform still cannot meet it. Concretely, ietf-interfaces does not anticipate a chassis that cannot expose a particular counter, so no feature guards that node; the platform must emit a deviation declaring the counter not-supported. A second adjacent confusion is augment, which inserts brand-new nodes at a target path rather than altering an existing node's properties — an augment enlarges the model, a deviation narrows or adjusts it. Keeping the trio distinct explains why option A speaks of implementation differences, while features, augments and imports describe capabilities, extensions and dependencies respectively.

Schema resolution at session setup is where a deviate not-supported changes what a client may send

The statement does its work before any configuration edit is attempted. When a NETCONF session opens, the server's hello announces its base capability plus a capability entry for every implemented module and every deviation module, and a read of the YANG library data (RFC 8525) enumerates them under deviations. A tool such as ncclient, or a RESTCONF client building JSON from a model, must merge the base module with those deviation files to derive the effective schema, and only then generate payloads. Skip that merge and the payload still mentions the excised leaf, so the device answers with an unknown-element error; if the deviation replaced a range or a default, the same payload returns invalid-value or applies a default the client never assumed. The same resolution governs operations: a model-driven telemetry subscription filtered on a node the device marked not-supported is refused when the subscription is created rather than failing silently at sampling time. RESTCONF inherits the behaviour unchanged, since RFC 8040 reuses the YANG data model and the same server-side schema.

Official Reference

Exam Strategy

When a YANG item asks you to identify a statement, translate the term into its RFC 7950 role before reading the options: deviation equals declared implementation difference, revision equals version history, import equals dependency, and error-message or error-app-tag equals error text. Then hunt for vendor artefacts that betray the answer, such as module names ending in -deviation or a deviations leaf-list in the YANG library. Eliminate any choice whose statement already owns a different job, because only one option per set can describe the schema exception.

Practice All 300-435 Questions

Access 150 questions with complete answers and detailed explanations.

View Full 300-435 Practice Test →

← Back to 300-435 Study Guide