Skip to content

Fix unbound variable from get_ocp_docs.sh#86

Open
umago wants to merge 1 commit into
openstack-lightspeed:mainfrom
umago:unbound-var-ocp
Open

Fix unbound variable from get_ocp_docs.sh#86
umago wants to merge 1 commit into
openstack-lightspeed:mainfrom
umago:unbound-var-ocp

Conversation

@umago
Copy link
Copy Markdown
Contributor

@umago umago commented Jan 28, 2026

Trivial fix for the get_ocp_docs.sh script, trying to use it without setting the OLS_DOC_REPO and OCP_VERSIONS explicitly failed with an "unbound variable" error instead of fallbacking to the default values.

Summary by CodeRabbit

  • Improvements
    • Script now provides sensible default values for configuration, reducing required setup.
    • Enhanced path handling to correctly resolve relative directories to absolute paths.
    • Defaults to fetching OpenShift versions 4.16, 4.18, and latest when not explicitly specified.

Trivial fix for the get_ocp_docs.sh script, trying to use it without
setting the OLS_DOC_REPO and OCP_VERSIONS explicitly failed with an
"unbound variable" error instead of fallbacking to the default values.

Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
@umago umago requested a review from a team as a code owner January 28, 2026 14:00
Copy link
Copy Markdown
Contributor

@lpiwowar lpiwowar left a comment

Choose a reason for hiding this comment

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

Looks good to me!:)

Comment thread scripts/get_ocp_docs.sh
OLS_DOC_REPO=${OLS_DOC_REPO:-"https://github.com/openshift/lightspeed-rag-content.git"}
# OpenShift Versions to create DBs for
# If we set it to empty string, it will generate all the available ones.
OCP_VERSIONS=${OCP_VERSIONS:-"4.16 4.18 latest"}
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.

Existing code is tailored for our current make target.
Your change breaks it because we always pass it:

OCP_VERSIONS ?= ""

I advocate for removing the u on the set command.

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.

@Akrog how does the change break the compatibility with the Makefile exactly? Maybe my brain is not thinking enough today but I really do not see it.

IMO this changes keeps the existing behavior intact plus ensures that the script can be used nicely standalone even without the Makefile (by dealing with the unbound variable). I like it.

I would keep the -u. I like the strictness of it. But I do not have super strong opinion on this.

Copy link
Copy Markdown
Contributor Author

@umago umago Jan 29, 2026

Choose a reason for hiding this comment

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

@Akrog thanks for the review.

@lpiwowar I think he means as the comment in the code says, if the variable is empty it will generate the docs for all available versions. But with my change, if the variable is empty it will then fallback to the default values.

I think the behavior is strange but yeah my change does break that assumption indeed. I will keep this open so we can discuss what would be best.

For context, the reason I made this change is because I was working on the per-rendering of the docs and I used the scripts in standalone mode, then I noticed this problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was looking at the code and if the variable is empty it will fallback to the default values as well... So I don't think this break anything ?

The comment in the code is not accurate, because in other to build all available versions we need to set OCP_VERSIONS="all"

# If "all" versions, we need to list them ourselves
if [ "$OCP_VERSIONS" == "all" ]; then
OCP_VERSIONS="$(find lightspeed-rag-content/ocp-product-docs-plaintext/* -maxdepth 0 -printf '%f ')"
fi

@lpiwowar
Copy link
Copy Markdown
Contributor

lpiwowar commented Mar 9, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6d543a2-61e6-49a4-b59a-19d2238b4e1a

📥 Commits

Reviewing files that changed from the base of the PR and between 1559818 and 74338a6.

📒 Files selected for processing (1)
  • scripts/get_ocp_docs.sh

📝 Walkthrough

Walkthrough

The script refactors environment variable initialization by setting defaults via parameter expansion instead of inline conditionals, and reorders variable declarations to establish directory context earlier in execution.

Changes

Cohort / File(s) Summary
Environment Variable Defaults & Directory Setup
scripts/get_ocp_docs.sh
Modified OLS_DOC_REPO and OCP_VERSIONS defaults using parameter expansion; added early initialization of SCRIPT_DIR, CURR_DIR, and OUTPUT_DIR_NAME with absolute path resolution; removed fallback _OCP_VERSIONS conditional; reordered execution flow to establish working directory context first.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A script now cleaner, with defaults so bright,
Variables set before first test in sight,
Directories declared, paths made true,
Working context ready—onward we flew!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing an unbound variable issue in get_ocp_docs.sh by adding proper default values for environment variables.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@lpiwowar
Copy link
Copy Markdown
Contributor

lpiwowar commented Mar 9, 2026

@umago I just wanted to check that we can trigger Code Rabbit on old PRs and this looked as a good candidate (it is a small change:).

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.

3 participants