Adding npm release service catalog scripts to utils - #367
Merged
dperaza4dustbit merged 1 commit intoAug 4, 2026
Merged
Conversation
Reviewer's GuideAdds npm release-related tooling and cosign to the shared utils image so Release Service Catalog tasks can use thin wrappers instead of inline bash, including a common helper for validating tarball member sizes and new npm-related scripts. Flow diagram for assert_tar_member_size helperflowchart TD
A[assert_tar_member_size archive member max_bytes] --> B[create_tmp_file mktemp]
B --> C[extract_member_with_tar_and_head]
C --> D[measure_size_with_wc]
D --> E{size_missing_or_zero}
E -->|yes| F[return 1]
E -->|no| G{size_gt_max_bytes}
G -->|yes| H[print_error_and_return_1]
G -->|no| I[return 0]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
assert_tar_member_size, togglingpipefailon/off without restoring the previous state can surprise callers that rely on a specificset -o pipefailsetting; consider capturing the prior state and restoring it at the end of the function. - The
curlinvocation in theContainerfiledoes not use--failor--show-error, so HTTP errors may be silently treated as success; adding these flags would make the cosign download step more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `assert_tar_member_size`, toggling `pipefail` on/off without restoring the previous state can surprise callers that rely on a specific `set -o pipefail` setting; consider capturing the prior state and restoring it at the end of the function.
- The `curl` invocation in the `Containerfile` does not use `--fail` or `--show-error`, so HTTP errors may be silently treated as success; adding these flags would make the cosign download step more robust.
## Individual Comments
### Comment 1
<location path="utils/scripts/npm-common.sh" line_range="8-19" />
<code_context>
+ local max_bytes="${3}"
+ local tmp size
+ tmp="$(mktemp)"
+ # head closes early on truncate; ignore SIGPIPE from tar under pipefail.
+ set +o pipefail
+ tar -xOf "${archive}" "${member}" 2>/dev/null \
+ | head -c "$((max_bytes + 1))" > "${tmp}" || true
+ set -o pipefail
+ size="$(wc -c < "${tmp}" | tr -d ' ')"
+ rm -f "${tmp}"
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Toggling `pipefail` inside the helper can unintentionally change the calling script’s shell options.
Because the function unconditionally disables and then re-enables `pipefail`, it can permanently enable `pipefail` for callers that had it off, altering later behavior. Please either snapshot the current shell options and restore them exactly on exit, or rewrite the pipeline to avoid changing `pipefail` (for example by explicitly handling SIGPIPE/exit codes on the `tar`/`head` pipeline).
```suggestion
assert_tar_member_size() {
local archive="${1}"
local member="${2}"
local max_bytes="${3}"
local tmp size had_pipefail=0
# Snapshot current pipefail setting so we can restore it exactly.
if set -o | grep -q 'pipefail'; then
had_pipefail=1
fi
tmp="$(mktemp)"
# head closes early on truncate; ignore SIGPIPE from tar under pipefail.
set +o pipefail
tar -xOf "${archive}" "${member}" 2>/dev/null \
| head -c "$((max_bytes + 1))" > "${tmp}" || true
if ((had_pipefail)); then
set -o pipefail
else
set +o pipefail
fi
size="$(wc -c < "${tmp}" | tr -d ' ')"
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: David Peraza <dperaza@redhat.com>
dperaza4dustbit
force-pushed
the
rsc_util_image_update_npm
branch
from
August 4, 2026 20:30
fddaff9 to
76221bc
Compare
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.
Release Service Catalog repo prefers no inline task logic and if any logic needed inline it should be python not bash. They actually OK with having most of the logic in our own utils in thin wrappers. Adding all npm release logic to our utils image and pinning that image in RSC tasks.
Summary by Sourcery
Add npm release support scripts and cosign tooling to the shared utils image for use by Release Service Catalog tasks.
New Features:
Enhancements:
Build: