Skip to content

fix: avoid stderr/stdout mixing in single_e2e.sh chart_info parsing#881

Merged
MaciejKaras merged 1 commit intomasterfrom
maciejk/fix-chart-info-parsing
Mar 11, 2026
Merged

fix: avoid stderr/stdout mixing in single_e2e.sh chart_info parsing#881
MaciejKaras merged 1 commit intomasterfrom
maciejk/fix-chart-info-parsing

Conversation

@MaciejKaras
Copy link
Collaborator

@MaciejKaras MaciejKaras commented Mar 10, 2026

Summary

scripts/evergreen/e2e/single_e2e.sh used 2>&1 when capturing chart_info from oci_chart_info.py. This caused Python's urllib3 RequestsDependencyWarning (emitted on stderr) to be prepended to the JSON stdout, producing a mixed string like:

.../requests/__init__.py:113: RequestsDependencyWarning: urllib3 ...
  warnings.warn(
{"repository": "dev/mongodb/helm-charts", "registry": "...", ...}

When this string was then piped into jq, it failed with: jq: parse error: Invalid numeric literal at line 1, column 102

Before:

if ! chart_info=$(scripts/dev/run_python.sh scripts/release/oci_chart_info.py \
    --build-scenario "${BUILD_SCENARIO}" 2>&1); then
    echo "${chart_info}"
    exit 1
fi
helm_oci_registry=$(echo "${chart_info}" | jq -r '.registry' )
...

After:

chart_info=$(scripts/dev/run_python.sh scripts/release/oci_chart_info.py \
    --build-scenario "${BUILD_SCENARIO}") || { echo "Failed to generate chart_info" ; exit 1; }

helm_oci_registry=$(echo "${chart_info}" | jq -r '.registry') || { echo "Failed to parse registry from chart_info"; exit 1; }
...

Removing 2>&1 means:

  • chart_info only ever contains clean JSON stdout
  • Errors (stderr) are printed naturally by the failing command before || triggers
  • Each jq extraction has explicit error handling that was missing before

Proof of Work

Tested with --build-scenario patch:

  • Python warnings print to terminal (stderr) as expected
  • chart_info contains clean JSON
  • All four fields (registry, repository, region, version_prefix) parse correctly

Error path verified: passing an invalid scenario prints the error from stderr, then the context echo fires — no mixed content in variables.

  echo "=== Test 1: chart_info command failure (invalid scenario) ===" && \
  chart_info=$(scripts/dev/run_python.sh scripts/release/oci_chart_info.py --build-scenario invalid_scenario 2>/dev/null) || \
  { echo "Failed to generate chart_info"; } && \
  echo "" && \
  echo "=== Test 1 (with stderr visible, as it would be in the script) ===" && \
  chart_info=$(scripts/dev/run_python.sh scripts/release/oci_chart_info.py --build-scenario invalid_scenario) || \
  { echo "Failed to generate chart_info"; }

  === Test 1: chart_info command failure (invalid scenario) ===
  Failed to generate chart_info
  === Test 1 (with stderr visible, as it would be in the script) ===
  /Users/maciej.karas/mongodb/mongodb-kubernetes/venv/lib/python3.13/site-packages/requests/__init__.py:113 RequestsDependencyWarning: urllib3 (2.6.3) or chardet (7.0.1)/charset_normalizer (3.4.4) doesn't match a supported version!
  warnings.warn(
  usage: oci_chart_info.py [-h] -b
  oci_chart_info.py: error: argument -b/--build-scenario: invalid choice: 'invalid_scenario' (choose from release, patch, staging, development)
  Failed to generate chart_info
  <exited with exit code 0>

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@MaciejKaras MaciejKaras requested a review from a team as a code owner March 10, 2026 09:44
@MaciejKaras MaciejKaras added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Mar 10, 2026
@MaciejKaras MaciejKaras requested a review from a team as a code owner March 10, 2026 09:44
@github-actions
Copy link

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.7.1 Release Notes

Other Changes

  • Container images: Merged the init-database and init-appdb init container images into a single init-database image. The init-appdb image will no longer be published and does not affect existing deployments.
  • Helm Chart: Removed operator.baseName Helm value. This value was never intended to be consumed by operator users and was never documented. The value controls the prefix for workload RBAC resource names (mongodb-kubernetes default), but changing it could break the operator and workloads because the operator is not aware of custom prefixes. With this change, the Helm chart will no longer allow customisation and the relevant resources will be deployed with predefined names (ServiceAccount with names mongodb-kubernetes-appdb, mongodb-kubernetes-database-pods, mongodb-kubernetes-ops-manager, Role with name mongodb-kubernetes-appdb and RoleBinding with name mongodb-kubernetes-appdb).

@MaciejKaras MaciejKaras changed the base branch from master to dependabot/pip/pip-deps-25329bb1b1 March 10, 2026 09:52
@MaciejKaras MaciejKaras force-pushed the maciejk/fix-chart-info-parsing branch from 3ba251f to dba8b30 Compare March 11, 2026 08:39
@MaciejKaras MaciejKaras changed the base branch from dependabot/pip/pip-deps-25329bb1b1 to master March 11, 2026 08:42
@MaciejKaras MaciejKaras added skip-changelog Use this label in Pull Request to not require new changelog entry file and removed skip-changelog Use this label in Pull Request to not require new changelog entry file labels Mar 11, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MaciejKaras MaciejKaras force-pushed the maciejk/fix-chart-info-parsing branch from dba8b30 to c0c77f9 Compare March 11, 2026 09:30
@MaciejKaras MaciejKaras enabled auto-merge (squash) March 11, 2026 09:30
@MaciejKaras MaciejKaras merged commit b9cee74 into master Mar 11, 2026
4 of 5 checks passed
@MaciejKaras MaciejKaras deleted the maciejk/fix-chart-info-parsing branch March 11, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use this label in Pull Request to not require new changelog entry file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants