Repository navigation
plugins types BUGFIX instance-identifier required instance error code - #2613
Open
lamestllama wants to merge 1 commit into
Open
lamestllama wants to merge 1 commit into
lamestllama wants to merge 1 commit into
Conversation
A missing required instance-identifier target returned LY_ENOTFOUND from ly_path_eval() instead of LY_EVALID, unlike a leafref, so multi-error validation also stopped at this error. Fixes CESNET#2608
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
lyplg_type_validate_tree_instanceid()insrc/plugins_types/instanceid.cnow returnsLY_EVALIDwhen a required instance-identifier target does not exist, with the existing error item (LYVE_DATA, app-taginstance-required, messageInvalid instance-identifier "..." value - required instance not found.). Before, it passed on the return value ofly_path_eval(), which is alwaysLY_ENOTFOUNDon failure. The leafref plugin already usesLY_EVALIDfor the same situation (src/plugins_types/leafref.c).Why
A missing required target is invalid data. RFC 7950, section 9.9.3: "If "require-instance" is "true", it means that the instance being referred to MUST exist for the data to be valid."
log.hsets the validation code together withLY_EVALID, and the error item already carriesLYVE_DATA; only the return code differed.The code also changed the behaviour of
LYD_VALIDATE_MULTI_ERROR:LY_VAL_ERR_GOTO()invalidation.ccontinues only afterLY_EVALID, so validation stopped at the instance-identifier error and the errors after it were lost. With this schema:and the data
<lr>x</lr><ii>/ri:t</ii>, multi-error validation returned 5 with only the instance-identifier error; it now returns 7 with both errors.Callers checked:
ly_path_eval()returns onlyLY_SUCCESSorLY_ENOTFOUND, so no other error is masked. The union plugin tries the next member type after any failure of a member, whatever the code (union_find_type()), and then reportsLY_EVALID.lyd_value_validate_incomplete(),lyd_value_validate3()and their callers (validation.c,path.c,xpath.c,tree_schema_common.c) treat any non-zero code as a failure and do not test forLY_ENOTFOUND. The only code that relied on it is in the unit tests: five expectations intests/utests/types/instanceid.cand one intests/utests/extensions/test_structure.c, updated toLY_EVALID.Fixes #2608
Test
test_require_instanceintests/utests/data/test_validation.c: a missing leafref target and a missing instance-identifier target are each refused withLY_EVALIDand theinstance-requiredapp-tag, and withLYD_VALIDATE_MULTI_ERRORboth errors are reported.test_data_xmlintests/utests/types/instanceid.candtest_parseintests/utests/extensions/test_structure.cnow expectLY_EVALID.Before the fix (updated tests, unchanged library):
utest_validationfailstest_require_instance(22 of 23 pass),utest_instanceidfailstest_data_xml(2 of 3) andutest_structurefailstest_parse(4 of 5). After the fix, all three pass, and the wholectestrun passes (69 of 69; Debug build, GCC 13.3, aarch64).