Validate Recipe entries before pipeline execution - #170
Merged
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H8NygEHhT3zGMnBmQF2F6Q
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.
Summary
pluginsentry: an entry must be a mapping, itsmodulemust be a required non-empty (non-whitespace-only) string, and itsconfigmust be either omitted/null or a mapping. A malformed entry is now refused asAutomatic::InvalidRecipeErrorat Recipe load time, identified by its index (e.g.plugins[2] is not a mapping).Automatic::Pipeline.runnow discovers every plugin module named in the Recipe (via the existingload_plugin) before running any plugin. If any module is undiscoverable,Automatic::NoPluginErroris raised before any plugin'sinitialize/runis called, regardless of where in the Recipe the unknown module is.load_pluginbehavior); a plugin's file is still read only when execution actually reaches that plugin's turn.Reason
doc/PLUGINS.md documents each
pluginsentry's shape (a mapping naming amodule, with an optionalconfigmapping) and documents an unknown plugin as refused before any plugin runs. Previously, malformed entries were not validated at the Recipe boundary and could surface as an internalNoMethodError/TypeErroronce the pipeline reached them, andPipeline.rundiscovered and executed each entry interleaved, so a typo'd module later in the Recipe was only discovered after any earlier plugin's side effect had already happened. This change makes both checks happen up front, before any plugin runs.Tests
bundle exec rspec spec/lib/automatic/recipe_safety_spec.rb— 20 examples, 0 failures.bundle exec rspec spec/lib/automatic/pipeline_spec.rb— 10 examples, 0 failures.bundle exec rake spec:lib— 108 examples, 0 failures.bundle exec rake spec— 403 examples, 0 failures.gem build automatic.gemspec— succeeded.bundle exec ruby -Ilib -e "require 'automatic'"— succeeded.bundle exec bin/automatic --versionand--help— succeeded.plugins:\n - nope) is refused withplugins[0] is not a mapping, and a Recipe with a valid plugin followed by an unknown one is refused withunknown plugin named ...before the valid plugin runs.New pipeline_spec.rb coverage includes a fixture plugin (
spec/user_dir/plugins/filter/load_marker.rb) used to check$LOADED_FEATURESdirectly, proving discovery does not read a plugin's source file even when an unknown module follows it, and that the file is read only once execution reaches it.Compatibility
Automatic::Recipe.new(path),Automatic::Recipe#each_plugin,Automatic::Pipeline.run(recipe)andAutomatic::Pipeline.load_plugin(module_name)keep their existing public call shapes.config,config: null, mappingconfig, repeated modules, and YAML aliases all continue to be accepted.VERSION, CLI, or Ruby-support change.Version History
Recorded as part of one consolidated
v26.09release item indoc/VERSIONS(the existing seven bullets in that section were also consolidated into two, at the user's explicit request in this session, to stop the section from growing by one bullet per change):VERSIONremains26.09; no version bump.🤖 Generated with Claude Code
https://claude.ai/code/session_01H8NygEHhT3zGMnBmQF2F6Q
Generated by Claude Code