Repository navigation
fix(validator): stop caching constraint focus paths and cap the AST cache - #2971
Open
angela-helios wants to merge 1 commit into
Open
angela-helios wants to merge 1 commit into
angela-helios wants to merge 1 commit into
Conversation
…ache The process-lifetime FHIRPath constraint evaluator cached every expression it parsed, focus paths included, and those carry the array indices of the resource being validated, so each distinct index added a permanent entry. Focus paths are now parsed per evaluation and not cached, and the invariant cache keeps at most 4096 entries. Closes #2970
This branch has not been deployed
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.
Closes #2970
Summary
FhirPathConstraintEvaluatorlives as long as the process and cached every expression it parsed, with no ceiling. That included the focus path of each constrained node, which carries the array indices of the resource being validated (contact[0],contact[1], …), so the cache grew by one permanent entry per distinct index any caller sent.helios_fhirpath::parse_expressionand not cached.MAX_CACHED_ASTS(4096) entries. Past that, a new invariant is parsed for its own evaluation and not kept, so tenant profiles with ever more distinct invariants cannot grow it without bound either.Tests
fhirpath_effects::tests::focus_paths_do_not_grow_the_ast_cache_and_invariants_are_capped(R4,fhirpathfeature):name.exists()on 50Patient.contact.Npaths passes and leaves one cache entry;With focus paths cached again and no ceiling, the first assertion fails with 51 entries.
cargo test -p helios-fhir-validator --features fhirpath: 142 passed. Clippy on the crate (--features fhirpath --lib --tests) is clean.