Repository navigation
fix(restore-jupyter-cache): refuse values outside each input's accepted set, and an empty path (#236) - #268
Merged
Merged
Conversation
…ed set (#236) unit-input-values runs a control that must pass, then one case per refused value, each differing from the control in one input: cache-type 'exec', save-cache 'True' with the generated keys and with a custom key, fail-on-miss 'yes', and an empty path with the execution cache. On its own, against restore-jupyter-cache as it is before the next commit, every refused case passes, so the job fails. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMavcZNRwucF4FkV3fo
…ed set, and an empty path (#236) The first step, Check inputs, now also reads cache-type, save-cache and fail-on-miss on every call, a custom key's included, and fails with an ::error:: on anything but build or execution and 'true' or 'false', and on an empty path. The steps compared these values exactly but their if: conditions case-insensitively, so save-cache 'True' registered the job-end save under the read-only key and the cache stopped updating without a word, cache-type 'exec' restored the build cache, and fail-on-miss 'yes' was false. An empty path put the execution cache in /.jupyter_cache. Each input's description names its accepted values, and the manual's Troubleshooting lists the new errors. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMavcZNRwucF4FkV3fo
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟢 Approval recommended
The change adds strict upfront input validation (including rejecting empty paths) and includes a dedicated CI harness plus updated docs/changelog, with no unresolved issues noted in the review evidence.
No open issues 🎉
What changed in this PR
This pull request hardens the restore-jupyter-cache composite action by validating enumerated inputs up front (and rejecting an empty path) so near-miss values that previously “half-worked” now fail fast before any cache restore/save side effects occur.
Changes:
- Extend
restore-jupyter-cache’sCheck inputsstep to strictly validatecache-type,save-cache, andfail-on-miss, and to refuse an emptypath, with workflow-command-safe escaping in error messages. - Add a harness CI job (
unit-input-values) to prove invalid inputs fail early and do not restore/create cache artifacts. - Regenerate/update user docs, developer testing docs, and the changelog to reflect the stricter accepted-value contract.
This pull request is ready to be approved.
| File | Summary |
|---|---|
restore-jupyter-cache/action.yml |
Adds strict early validation for enumerated inputs and empty path, centralizing safe value rendering for error messages. |
docs/user/actions/restore-jupyter-cache.md |
Regenerates the inputs table and documents troubleshooting for invalid values and empty path. |
docs/dev/TESTING.md |
Updates the testing matrix to include the new unit-input-values coverage for restore-jupyter-cache. |
CHANGELOG.md |
Records the behavior change under [Unreleased] → Changed. |
.github/workflows/test-actions.yml |
Introduces the unit-input-values harness job and wires it into the workflow dependencies/summary. |
Review effort: Balanced
This was referenced Nov 6, 2026
Merged
mmcky
added a commit
that referenced
this pull request
Nov 7, 2026
Move [Unreleased] into a dated 0.16.0 section, carrying waves 3 and 4 of #246: every value reaches a run: script through env: (#228), each action refuses a line break in a single-value input and escapes what it prints (#267), restore-jupyter-cache refuses unknown values (#236) and removes the restored HTML after a build-cache restore (#160), html-copy-notebooks keeps each notebook's path (#217), build-jupyter-cache's failure alert lands on an issue and its repro commands build into ./_build (#229, #238), and deploy-cloudflare's require-access is removed, the release's one breaking change (#177). CI gains actionlint and shellcheck (#100). PLAN drops #236, which #268 closed, and says #18 is parked until a repository passes environment-update. The release changes what every action does, so it is staged on the canary before v0 moves. Claude-Session: https://claude.ai/code/session_01WT8bMbMmeUUEj8EjiweB6S Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Nov 7, 2026
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.
restore-jupyter-cachechecked none of its enumerated inputs (#236, finding L3 of the 2026-10-06 review). Its shell steps comparecache-type,save-cacheandfail-on-missexactly, but itsif:conditions compare them case-insensitively, as GitHub's expressions compare strings. So a value that was nearly right half-worked, without a word. This PR makes the first step,Check inputs, which #265 added forkeyandpath, also check these three on every call, a customkey's included, and refuse an emptypath, before anything is restored or registered for saving.save-cache: 'True'if:registered the job-end save, but the key step read it as false and left the run ID off the key. The first run saved under the read-only key; every later run matched it exactly, saved nothing, and the pull request's cache stopped updatingCheck inputscache-type: exec, or any other typofail-on-miss: yespath: ''cache-type: execution, restored into/.jupyter_cache. Withbuild, failed insideactions/cache("Input required and not supplied: path")build,execution,'true','false', or an unquotedtrueorTrueEach error names the input and the value, escaped as a workflow command's data, as #265's line-break check does: for example
save-cache must be 'true' or 'false', got 'True'. Every bad input is reported in one run, not only the first.Changes
restore-jupyter-cache/action.ymlCheck inputsreadscache-type,save-cacheandfail-on-missfromenv:and refuses anything outsidebuild/executionand'true'/'false'. It also refuses an emptypath. The escaping is now one helper,shown, used by every message. Its comment says why: theif:comparisons are case-insensitive. The descriptions ofcache-type,path,save-cacheandfail-on-misssay what is accepted, and that anything else fails the run..github/workflows/test-actions.ymlunit-input-values, besideunit-line-break, and inharness-summary'sneeds:beside it. See below.docs/user/actions/restore-jupyter-cache.mddocs/dev/TESTING.mdrestore-jupyter-cacherow listsunit-input-values. Same arrangement as #265's edit.CHANGELOG.md[Unreleased],### Changed, without theunit-input-values. Modelled onbjc-builders-parse: a control that must pass (build, read-only, a salted miss), then one step per refused value, each differing from the control in one input:cache-type: 'exec';save-cache: 'True', with the generated keys and again with a customkey, since restore-jupyter-cache: a mis-cased save-cache value silently stops the cache updating, and unknown input values are accepted #236 asks for the check on every call;fail-on-miss: 'yes';pathwithcache-type: 'execution', the case that succeeded before.The job asserts each outcome, that
cache-hitstays'false', and that neither_buildnor/.jupyter_cacheexists.'True'is quoted in the job, because YAML reads an unquotedTrueas the boolean.Callers, and the⚠️ BREAKING question
This can fail a caller's workflow that works today, if it passes one of these values. Before writing the entry, I looked for such callers:
quantecon/actions/restore-jupyter-cache,restore-jupyter-cache,save-cacheandfail-on-miss.lecture-dpci.yml,publish.ymltest-actions-lecture-intro(canary)ci.ymlcache-type: 'build',source-dir: 'lectures',save-cache: 'true'templates/ci.ymlcache-type: 'build', withsave-cache: 'true'andfail-on-miss: 'false'as comments'true',executionand the defaultsNeither repository's
cache.yml, nor the canary'spublish.yml, uses the action. No other consumer in PLAN's table does either, and nothing passespath. So no known caller passes a refused value.The runner reads workflow YAML with the YAML 1.2 core schema (
MatchBooleanin actions/runner'sYamlObjectReader.cs). Sotrue,TrueandTRUE, unquoted, are booleans, and the action receives'true'; the same goes forfalse. Only a quoted'True', or a value such asyes,onor1, which YAML 1.2 does not treat as a boolean, reaches the action as written and is refused.The maintainer has decided: no marker, under Changed. No known caller is affected, and every refused value either half-worked or did something other than what it said.
What I checked, and how
The issue's premises, on ea01c01. #265 moved these values into
env:without changing what they do, so #236's descriptions still hold, at new line numbers:[ "$SAVE_CACHE" = "true" ], and the save stepif: inputs.save-cache == 'true'.cache-typeis compared only toexecutionin the key and path steps.executionandbuildseparately.Its pointer to
deploy-cloudflare/action.yml:120-123is stale. That action now validates in afail()helper from line 114, withvisibilitybeside the deprecatedrequire-access, and the messages here follow its wording.The new job fails on
main. I pushed the harness commit on its own first, da0caa0, on top of ea01c01, and dispatched the harness on it.unit-input-valuesfailed: the control passed, and all five refused cases passed too. In the log:execrestored withpath: _buildand the report saidCache Type: exec.save-cache: 'True'cases ran "Register job-end cache save".fail-on-miss: 'yes'carried on.path: /.jupyter_cache.This PR's own run is the same job on the fixed action.
Check inputs, locally. I ran it in isolation under bash 3.2, with each case's values inenv:. In 16 cases, it:$;exec,Build, an emptycache-type,'True'with and without a custom key,yes, an emptyfail-on-miss, an empty path for each type, a line break incache-type,keyorpath, and a value with spaces and a glob;::error::lines, and nothing to$GITHUB_OUTPUT, with%, CR and LF escaped;The first run of these tests caught a bug in my own escaping: inside double quotes, bash 3.2 kept the single quotes of
"${s//$'\n'/'%0A'}"literally. Each substitution is now a plain assignment, as inbuild-lectures.Nothing else changed. The same comparison as #265's,
main's steps against this branch's for valid inputs, still gives 56 cases and 0 differences: no step other thanCheck inputschanged.Lint. actionlint run as the gate runs it, over
.github/workflows/with shellcheck 0.11.0 at its default severity, reports nothing. shellcheck finds nothing inrestore-jupyter-cache'srun:blocks, and norun:text has a${{, which lint's #266 will enforce.python3 scripts/generate-docs.py --check --check-examples --actionlint …passes.What to watch after merge
This changes what
restore-jupyter-cacheaccepts, so it ships in a staged release (CONTRIBUTING, Staged Releases). In a canary branch with everyquantecon/actions/...@v0changed to the staged tag:ci.ymlon a canary pull request, as it is:cache-type: 'build',save-cache: 'true'. The restore finds the cache, and the job-end save happens, with the run ID in its key.save-cache: 'True'(quoted). The job fails atrestore-jupyter-cache's first step, withsave-cache must be 'true' or 'false', got 'True', and nothing is restored.publish.ymlon a test tag is unchanged, since it doesn't use the action, but a run confirms the chain.#160
This makes #160 safer. If
cache-type: executionbecomes the templates' default to avoid stale pages, a mistyped value can no longer bring the whole build cache back without a word. #160's decision itself is not in this PR.Not in this PR
setup-environment. It spans 30 lines in six actions, and is my next PR. This PR's own messages are escaped.--path-output#229 and build-jupyter-cache: the failure alert can land on an open pull request instead of an issue #238, later items in these actions.Closes #236
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMavcZNRwucF4FkV3fo