Skip to content

NUTCH-3197 Yetus: fix real precommit defects (shell, Docker, shelldocs) - #958

Open
lewismc wants to merge 3 commits into
apache:masterfrom
lewismc:NUTCH-3197
Open

lewismc wants to merge 3 commits into
apache:masterfrom
lewismc:NUTCH-3197

Conversation

@lewismc

@lewismc lewismc commented Aug 16, 2026

Copy link
Copy Markdown
Member

PR for NUTCH-3197

Follow-up to NUTCH-3196 (Child A: Yetus false-positive baselines). This is Child B of the Yetus master precommit initiative: fix real defects the gate correctly reported, without taking on historical style debt (Child C) or shellcheck warnings/notes (Child D).

Fork: lewismc/nutchapache/nutch (replaces incorrectly opened #956 from upstream branch).

Summary

  • Fix 11 shellcheck errors in src/bin/crawl and src/bin/nutch (SC2071, SC2144, SC2242, SC2145) with behavior-preserving edits
  • Fix SC2006 on cygpath line introduced by the SC2144 refactor ($(...) instead of backticks)
  • Add @audience / @stability shelldocs annotations to five helper functions in src/bin/crawl
  • Restructure docker/Dockerfile for hadolint (combined RUNs, quoting); waive DL3018 via .hadolint.yaml
  • Exclude src/plugin/parse-js/sample/ from jshint via .yetus/excludes.txt (test fixture, not production JS)

Product codespell typos are in a linked follow-up PR from the same fork.

Out of scope (sibling issues)

  • Historical blanks/tabs, @author, markdownlint → Child C (NUTCH-3198)
  • Shellcheck warnings/notes in bin scripts → Child D (NUTCH-3199)
  • Product codespell typos → linked PR from NUTCH-3197-codespell

Test plan

  • ant clean runtime test
  • shellcheck -S error src/bin/crawl src/bin/nutch — no errors
  • Yetus CI clears shellcheck, shelldocs, hadolint, jshint on changed lines

…ocs)

Child B of the Yetus master precommit initiative (follows NUTCH-3196).
Fix shellcheck errors in bin/crawl and bin/nutch, add shelldocs annotations,
restructure docker/Dockerfile for hadolint, exclude parse-js test sample
from jshint, and waive DL3018 apk pinning via .hadolint.yaml.
…tion refactor

Replace legacy backticks with $() on the cygpath assignment moved into the
for-loop by the SC2144 fix so Yetus patch mode no longer reports a new
shellcheck note on PR 956.

@sebastian-nagel sebastian-nagel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @lewismc. Looks good.

The exit values may need some extra review / thinking.

Comment thread src/bin/nutch
local=false
for f in "$NUTCH_HOME"/*nutch*.job; do
# NUTCH_JOB
for f in "${NUTCH_HOME}"/*nutch*.job; do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are two or more job files in NUTCH_HOME, that's already an issue very likely. But ok for this fix. If we are lucky the last job file is the right one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. More than one nutch.job already means a messy NUTCH_HOME. This change only makes the glob shellcheck-safe and takes the first match. Happy to fail closed on multiples in a follow-up if you want that.

Comment thread src/bin/nutch
# check that hadoop can be found on the path
if [ $(which hadoop | wc -l ) -eq 0 ]; then
echo "Can't find Hadoop executable. Add HADOOP_COMMON_HOME/bin to the path or run in local mode."
exit -1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat sensitive because the script bin/crawl expects that bin/nutch generate ... exits with code 1 when no segment was created. All errors should ideally use other error codes.

Of course, this is not 100% working, because the Generator uses Hadoop's ToolRunner which maps exceptions (don't whether all) to 1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should change the behavior of Generator and exit with a more unique code, in case no segment was created (nothing to fetch). But would be a breaking change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this was some education for me. 1 would mean “no segment” for bin/crawl + Generator... which is misleading/incorrect.
A missing Hadoop is now exit 127 (POSIX utility-not-found) in bin/nutch and bin/crawl, so that path is no longer confused with an empty generate. ToolRunner still mapping some exceptions to 1 is unchanged.

@github-actions

github-actions Bot commented Sep 13, 2026

Copy link
Copy Markdown

Apache Yetus test-patch report

+1 overall
Vote Subsystem Runtime Log Comment
Prechecks
+1 dupname 0m 0s No case conflicting files found.
+1 @author 0m 0s The patch does not contain any @author tags.
master Compile Tests
Patch Compile Tests
+1 codespell 0m 1s The patch generated 0 new + 0 unchanged - 1 fixed = 0 total (was 1)
+1 detsecrets 0m 22s No new issues.
+1 blanks 0m 0s The patch has no blanks issues.
+1 hadolint 0m 0s The patch generated 0 new + 1 unchanged - 8 fixed = 1 total (was 9)
+1 markdownlint 0m 1s No new issues.
+1 shellcheck 0m 1s The patch generated 0 new + 64 unchanged - 12 fixed = 64 total (was 76)
+1 shelldocs 0m 0s The patch generated 0 new + 0 unchanged - 10 fixed = 0 total (was 10)
+1 yamllint 0m 0s No new issues.
Other Tests
+1 asflicense 0m 1s The patch does not generate ASF License warnings.
0m 30s
Subsystem Report/Notes
GITHUB PR #958
Optional Tests dupname asflicense codespell detsecrets hadolint shellcheck shelldocs yamllint markdownlint
uname Linux a3f1b7ef9d0b 6.17.0-1022-azure #22-Ubuntu SMP Mon Jul 27 17:24:03 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool nobuild
Personality /github/workspace/.yetus/personality.sh
git revision master / 7deccaa
modules C: . U: .
versions git=2.34.1 hadolint=2.12.0 codespell=2.4.1 detsecrets=1.5.0 markdownlint=0.44.0 shellcheck=0.10.0 yamllint=1.35.1
Powered by Apache Yetus 0.15.1 https://yetus.apache.org

This message was automatically generated.

@lewismc

lewismc commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Hi @sebastian-nagel thanks for the review. In summary, this PR now keeps generate’s 1. Env/Hadoop-not-found is 127.

A dedicated empty-generate code can be its own JIRA if we want to break that contract... I didn't bother here.

I'll leave this open for a while longer, if you want to revisit. Thanks.

@lewismc lewismc self-assigned this Sep 18, 2026
@lewismc lewismc closed this Sep 18, 2026
@lewismc lewismc reopened this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants