fix: map WRAP_ACTIONS in the ModelExtension binding - #322
Open
wyongzhi wants to merge 1 commit into
Open
Conversation
PyModelExtension was missing WRAP_ACTIONS, so the catch-all arm in From<ModelExtension> for PyModelExtension silently reported it as EXPR. A profile built with WRAP_ACTIONS enabled EXPR instead, and templates using onWrapEnvEnter/onWrapTaskRun/onWrapEnvExit were rejected with an error that did not name the cause. The catch-all cannot be removed because openjd_model::ModelExtension is non_exhaustive, so TestModelExtension guards the mapping instead: it fails when the binding enum drifts from ExtensionName, or when any spec name parses back to a different member. The pickle round-trip list also gains the new member. Signed-off-by: Yongzhi Wei <276409147+wyongzhi@users.noreply.github.com>
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 was the problem/requirement? (What/Why)
PyModelExtensionwas missing theWRAP_ACTIONSmember, so the mandatory catch-all arm inFrom<ModelExtension> for PyModelExtensionsilently reported it asEXPR. AModelProfilebuilt withWRAP_ACTIONStherefore enabledEXPRinstead, and templates usingonWrapEnvEnter/onWrapTaskRun/onWrapEnvExitwere rejected with an error that did not name the real cause.Minimal repro on 0.11.1:
Why it was missed:
WrapActionslanded in the Rust crate after this binding's enum was written. #285, #306, and #318 all touched WRAP_ACTIONS support in the template layer (template_types.rs,_model.py), but none touchedprofile.rs, where the extension-enablement enum lives. Because upstreamModelExtensionis#[non_exhaustive], the catch-all arm is compiler-mandated, so the missing arm produced no warning.What was the solution? (How)
WRAP_ACTIONS = 4toPyModelExtensionand bothFromconversion armsEXPR, and document the three edits a new upstream variant needs.pyistubTestModelExtension(drift guard): asserts the binding's member set equalsopenjd.model.v2023_09.ExtensionName, and that every spec name round-trips to its own member viafrom_str. Either test fails on the next unmapped variant. This is the guard the compiler cannot provide under#[non_exhaustive].WRAP_ACTIONSto the pickle round-trip parametrize listWhat is the impact of this change?
ModelProfilebuilt withWRAP_ACTIONS(directly, viafrom_strings, or from a template'sextensions:list) now actually enables WRAP_ACTIONS. This unblocks downstream consumers that declaresupported_extensionsfromExtensionName, for which WRAP_ACTIONS was silently never enabled.How was this change tested?
test_name_round_trips_to_its_own_member[WRAP_ACTIONS]fails without the fix and passes with itruff,black,mypycleanWas this change documented?
.pyistub lists the new member.Is this a breaking change?
No. It adds an enum member and corrects a mapping; no existing public contract changes. Code that (incorrectly) relied on
from_str("WRAP_ACTIONS")returningEXPRwould change behavior, but that behavior was the defect.Does this change impact security?
No. No new files, directories, or privilege boundaries; no threat modeling needed.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.