Skip to content

SREP-3893 CVE fix and go mod bump. Update the deployment to clusterpa…#433

Open
tkong-redhat wants to merge 1 commit intoopenshift:masterfrom
tkong-redhat:SREP-3893-CVE-fix-Mar
Open

SREP-3893 CVE fix and go mod bump. Update the deployment to clusterpa…#433
tkong-redhat wants to merge 1 commit intoopenshift:masterfrom
tkong-redhat:SREP-3893-CVE-fix-Mar

Conversation

@tkong-redhat
Copy link

@tkong-redhat tkong-redhat commented Mar 24, 2026

CVE fix and go mod bump.
Update the deployment to clusterpackage instead of SSS.

Tested locally. Certman operator can start without issue

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Walkthrough

This pull request updates multiple infrastructure and dependency layers: image tags are bumped to v8.3.4, team memberships are adjusted in OWNERS_ALIASES files, E2E test templates are refactored to use Slack-based notifications instead of cloud credential parameters, and the PKO migration script is enhanced to support custom cluster deployment selectors and improved YAML manifest handling. Test infrastructure is modernized with updated Kubernetes asset versions, and Go module dependencies are upgraded across the board.

Changes

Cohort / File(s) Summary
Image and Version Updates
.ci-operator.yaml, boilerplate/_data/backing-image-tag, build/Dockerfile, build/Dockerfile.olm-registry, boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry
Updated base image tags: boilerplate image from image-v8.3.3 to image-v8.3.4, OpenShift operator registry from v4.19 to v4.21, and UBI minimal runtime from 9.7-1773204619 to 9.7-1773939694.
Team Membership Updates
OWNERS_ALIASES, boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES
Removed hectorakemp from and added gvnnn to srep-functional-team-orange; removed rogbas and bng0y from srep-team-leads.
E2E Template Refactoring
boilerplate/openshift/golang-osd-e2e/e2e-template.yml, test/e2e/e2e-template.yml
Replaced OCM/AWS/GCP credential parameters with Slack notification parameters (SLACK_NOTIFY, SLACK_CHANNEL). Added --log-analysis-enable and --secret-locations flags. Consolidated test configuration into TEST_SUITES_YAML and added corresponding Secret-backed volume mounts.
PKO Migration Script Enhancement
boilerplate/openshift/golang-osd-operator/olm_pko_migration.py
Added extract_deployment_selector() function to read custom cluster deployment selectors from OLM artifacts template. Updated Tekton PipelineRun naming to use event_name parameter. Extended ClusterPackage template with OPERATOR_IMAGE parameter. Switched YAML manifest parsing from yaml.safe_load to yaml.safe_load_all for multi-document support.
ClusterPackage Template Migration
hack/pko/clusterpackage.yaml
Migrated from hive.openshift.io/v1 SelectorSyncSet to package-operator.run/v1alpha1 ClusterPackage. Removed ENVIRONMENT and NAMESPACE parameters, added FEDRAMP parameter, restructured metadata and spec layout for direct ClusterPackage creation.
Test Infrastructure Updates
boilerplate/openshift/golang-osd-operator/standard.mk, boilerplate/openshift/golang-osd-operator/test_olm_pko_migration.py
Upgraded Kubernetes asset version from 1.23 to 1.28.0. Refactored go-test target to compute KUBEBUILDER_ASSETS at runtime via explicit setup-envtest invocation. Added comprehensive unit tests for extract_deployment_selector() and updated ClusterPackage template generation tests.
Metadata and Dependency Updates
boilerplate/_data/last-boilerplate-commit, go.mod
Updated boilerplate commit hash. Upgraded Go module dependencies including github.com/go-logr/logr, github.com/stretchr/testify, OpenTelemetry stack, google.golang.org/grpc, and various indirect utility libraries.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci openshift-ci bot requested review from YiqinZhang and anispate March 24, 2026 08:16
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 24, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tkong-redhat

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 24, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 24, 2026

@tkong-redhat: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.15%. Comparing base (2b3dedf) to head (d23ab94).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #433   +/-   ##
=======================================
  Coverage   57.15%   57.15%           
=======================================
  Files          29       29           
  Lines        2138     2138           
=======================================
  Hits         1222     1222           
  Misses        802      802           
  Partials      114      114           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry (1)

1-7: ⚠️ Potential issue | 🟠 Major

Pin the runtime base image to a specific version instead of mutable latest.

Line 7 uses ubi-minimal:latest, which introduces non-deterministic builds and silent CVE/regression drift. Even though the builder image was pinned to v4.21 on Line 1, the runtime base must also be pinned to a specific version tag.

Proposed fix
-FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
+FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7-1773939694
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry` around
lines 1 - 7, The runtime base image is pinned to a mutable tag
`registry.access.redhat.com/ubi9/ubi-minimal:latest`; update the Dockerfile's
second FROM to a specific, immutable UBI9 image tag (for example a
vendor-provided patch-level tag) to ensure reproducible builds; modify the line
that currently reads `FROM registry.access.redhat.com/ubi9/ubi-minimal:latest`
to reference a concrete version (matching your security/support policy) so the
runtime stage is deterministic and aligns with the pinned builder stage.
go.mod (1)

12-114: ⚠️ Potential issue | 🔴 Critical

go.sum must be included in this PR.

When go.mod is updated, go.sum must be regenerated with the correct checksums—this is a Go tooling requirement. The repository already has a go.sum file (584 lines), so it must be committed alongside these changes.

Additionally, the PR title references "SREP-3893" but provides no details on which specific CVEs these dependency updates address. Clarify the security fixes in the PR description: for example, the golang.org/x/crypto v0.46.0 and golang.org/x/net v0.48.0 updates address multiple 2025 CVEs (CVE-2025-58181, CVE-2025-47914, CVE-2025-22870, etc.). Specify which vulnerabilities this PR resolves.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` around lines 12 - 114, The PR updated go.mod but omitted the
regenerated go.sum—run `go mod tidy` (or `go mod download`) to regenerate go.sum
and commit that file alongside the go.mod changes so checksums match; also
update the PR description to list the specific security fixes addressed (mention
the updated modules like golang.org/x/crypto v0.46.0 and golang.org/x/net
v0.48.0 and the CVE identifiers such as CVE-2025-58181, CVE-2025-47914,
CVE-2025-22870 or whichever are fixed) so reviewers can verify which
vulnerabilities SREP-3893 is resolving.
boilerplate/openshift/golang-osd-operator/olm_pko_migration.py (1)

199-244: ⚠️ Potential issue | 🟠 Major

Align CLUSTERPACKAGE_TEMPLATE with the new direct ClusterPackage deployment.

write_clusterpackage_template() still serializes a SelectorSyncSet wrapper here, but the checked-in target in hack/pko/clusterpackage.yaml at Lines 20-32 is now a top-level package-operator.run/v1alpha1 ClusterPackage. The next regeneration will undo this PR and reintroduce the old SSS-based layout.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@boilerplate/openshift/golang-osd-operator/olm_pko_migration.py` around lines
199 - 244, The CLUSTERPACKAGE_TEMPLATE constant still emits a SelectorSyncSet
wrapper (via CLUSTERPACKAGE_TEMPLATE) while the desired artifact is now a
top-level package-operator.run/v1alpha1 ClusterPackage; update
write_clusterpackage_template() to serialize and write a top-level
ClusterPackage YAML matching hack/pko/clusterpackage.yaml (remove the
SelectorSyncSet envelope and ensure metadata/name, spec.image and
spec.config.image use the same parameter substitutions like {operator_name},
${PKO_IMAGE}:${IMAGE_TAG} and ${OPERATOR_IMAGE}:${IMAGE_TAG}), and update
CLUSTERPACKAGE_TEMPLATE accordingly so future regenerations produce the direct
ClusterPackage resource instead of the SSS wrapper.
boilerplate/openshift/golang-osd-operator/standard.mk (1)

248-281: ⚠️ Potential issue | 🟠 Major

Use host OS and architecture for envtest binaries.

Line 275 hardcodes --arch amd64 --os linux, but the binaries downloaded and executed by setup-envtest (kube-apiserver, etcd, kubectl) must run on the host machine. This breaks on non-linux/amd64 systems such as macOS/arm64 and non-amd64 builders.

Replace the hardcoded values with GOHOSTOS and GOHOSTARCH to detect the actual host platform:

Suggested fix
 ENVTEST_K8S_VERSION = 1.28.0
 SETUP_ENVTEST_VERSION = release-0.23
 GOPATH ?= $(shell go env GOPATH)
 SETUP_ENVTEST = $(GOPATH)/bin/setup-envtest
+ENVTEST_HOST_OS ?= $(shell go env GOHOSTOS)
+ENVTEST_HOST_ARCH ?= $(shell go env GOHOSTARCH)
@@
-	if ! ASSETS_PATH=$$($(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --arch amd64 --os linux --bin-dir /tmp/envtest-binaries -p path 2>&1); then \
+	if ! ASSETS_PATH=$$($(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --arch $(ENVTEST_HOST_ARCH) --os $(ENVTEST_HOST_OS) --bin-dir /tmp/envtest-binaries -p path 2>&1); then \
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@boilerplate/openshift/golang-osd-operator/standard.mk` around lines 248 -
281, The go-test recipe hardcodes --arch amd64 --os linux when invoking
$(SETUP_ENVTEST) which breaks on non-linux/amd64 hosts; update the invocation in
the go-test target to pass the host platform by using GOHOSTOS and GOHOSTARCH
(e.g., replace the literal flags after the use $(ENVTEST_K8S_VERSION) call with
--arch $(GOHOSTARCH) --os $(GOHOSTOS) or equivalent environment expansion) so
the SETUP_ENVTEST download produces binaries that match the host; keep
references to ENVTEST_K8S_VERSION and SETUP_ENVTEST unchanged and ensure the
ASSETS_PATH capture and subsequent KUBEBUILDER_ASSETS export remain the same.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@boilerplate/openshift/golang-osd-e2e/e2e-template.yml`:
- Around line 98-101: The TEST_SUITES_YAML block emits an unquoted slackChannel
scalar which lets values like `#channel` be treated as a YAML comment and lost;
update the TEST_SUITES_YAML value so slackChannel uses a quoted interpolation
(i.e. wrap ${SLACK_CHANNEL} in quotes) to preserve literal channels, and apply
the identical change to the e2e-template.yml copy; ensure you only modify the
slackChannel line (leave TEST_IMAGE and IMAGE_TAG interpolation untouched).

In `@boilerplate/openshift/golang-osd-operator/olm_pko_migration.py`:
- Around line 662-668: The selector YAML is being indented by 6 spaces
(indented_lines = ["      " + line ...]) which mis-nests the block and produces
`clusterDeploymentSelector: null`; update the indentation so the dumped selector
lines align as a proper YAML block under the clusterDeploymentSelector key
(e.g., indent by 8 spaces or compute indentation to match the template) by
changing the prefix used when building indented_lines (reference selector_yaml
and indented_lines) so the selector's top-level keys
(matchLabels/matchExpressions) appear nested under clusterDeploymentSelector.
- Around line 698-701: Remove the unnecessary f-string prefixes on the two print
calls in the conditional block (the lines printing "Please review this file and
ensure the deployment targets match your expectation" and the preceding warning
line) by replacing f"...” with regular string literals "..."; locate the print
statements in olm_pko_migration.py (the block that prints the default
clusterDeploymentSelector warning) and remove the leading "f" characters so Ruff
F541 is resolved.

---

Outside diff comments:
In `@boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry`:
- Around line 1-7: The runtime base image is pinned to a mutable tag
`registry.access.redhat.com/ubi9/ubi-minimal:latest`; update the Dockerfile's
second FROM to a specific, immutable UBI9 image tag (for example a
vendor-provided patch-level tag) to ensure reproducible builds; modify the line
that currently reads `FROM registry.access.redhat.com/ubi9/ubi-minimal:latest`
to reference a concrete version (matching your security/support policy) so the
runtime stage is deterministic and aligns with the pinned builder stage.

In `@boilerplate/openshift/golang-osd-operator/olm_pko_migration.py`:
- Around line 199-244: The CLUSTERPACKAGE_TEMPLATE constant still emits a
SelectorSyncSet wrapper (via CLUSTERPACKAGE_TEMPLATE) while the desired artifact
is now a top-level package-operator.run/v1alpha1 ClusterPackage; update
write_clusterpackage_template() to serialize and write a top-level
ClusterPackage YAML matching hack/pko/clusterpackage.yaml (remove the
SelectorSyncSet envelope and ensure metadata/name, spec.image and
spec.config.image use the same parameter substitutions like {operator_name},
${PKO_IMAGE}:${IMAGE_TAG} and ${OPERATOR_IMAGE}:${IMAGE_TAG}), and update
CLUSTERPACKAGE_TEMPLATE accordingly so future regenerations produce the direct
ClusterPackage resource instead of the SSS wrapper.

In `@boilerplate/openshift/golang-osd-operator/standard.mk`:
- Around line 248-281: The go-test recipe hardcodes --arch amd64 --os linux when
invoking $(SETUP_ENVTEST) which breaks on non-linux/amd64 hosts; update the
invocation in the go-test target to pass the host platform by using GOHOSTOS and
GOHOSTARCH (e.g., replace the literal flags after the use $(ENVTEST_K8S_VERSION)
call with --arch $(GOHOSTARCH) --os $(GOHOSTOS) or equivalent environment
expansion) so the SETUP_ENVTEST download produces binaries that match the host;
keep references to ENVTEST_K8S_VERSION and SETUP_ENVTEST unchanged and ensure
the ASSETS_PATH capture and subsequent KUBEBUILDER_ASSETS export remain the
same.

In `@go.mod`:
- Around line 12-114: The PR updated go.mod but omitted the regenerated
go.sum—run `go mod tidy` (or `go mod download`) to regenerate go.sum and commit
that file alongside the go.mod changes so checksums match; also update the PR
description to list the specific security fixes addressed (mention the updated
modules like golang.org/x/crypto v0.46.0 and golang.org/x/net v0.48.0 and the
CVE identifiers such as CVE-2025-58181, CVE-2025-47914, CVE-2025-22870 or
whichever are fixed) so reviewers can verify which vulnerabilities SREP-3893 is
resolving.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4777d075-aaf1-4f1d-9b3b-3b85e9dce0a7

📥 Commits

Reviewing files that changed from the base of the PR and between 2b3dedf and d23ab94.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • .ci-operator.yaml
  • OWNERS_ALIASES
  • boilerplate/_data/backing-image-tag
  • boilerplate/_data/last-boilerplate-commit
  • boilerplate/openshift/golang-osd-e2e/e2e-template.yml
  • boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry
  • boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES
  • boilerplate/openshift/golang-osd-operator/olm_pko_migration.py
  • boilerplate/openshift/golang-osd-operator/standard.mk
  • boilerplate/openshift/golang-osd-operator/test_olm_pko_migration.py
  • build/Dockerfile
  • build/Dockerfile.olm-registry
  • go.mod
  • hack/pko/clusterpackage.yaml
  • hack/test/test-clusterpackage.yaml
  • test/e2e/e2e-template.yml

Comment on lines +98 to +101
- name: TEST_SUITES_YAML
value: |-
- image: ${TEST_IMAGE}:${IMAGE_TAG}
slackChannel: ${SLACK_CHANNEL}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n 'slackChannel:\s*\$\{SLACK_CHANNEL\}'

python - <<'PY'
import sys, subprocess
try:
    import yaml
except ImportError:
    subprocess.check_call([sys.executable, "-m", "pip", "install", "PyYAML", "-q"])
    import yaml

bad = "- image: quay.io/example/osde2e:v1\n  slackChannel: `#alerts`\n"
good = '- image: quay.io/example/osde2e:v1\n  slackChannel: "#alerts"\n'

print("unquoted:", yaml.safe_load(bad))
print("quoted  :", yaml.safe_load(good))
PY

Repository: openshift/certman-operator

Length of output: 414


Quote SLACK_CHANNEL inside TEST_SUITES_YAML to prevent silent failures.

Lines 98–101 emit an unquoted YAML scalar for slackChannel. When a caller passes #channel, YAML treats # as a comment delimiter, causing slackChannel to parse as null and the notification target to be silently lost. Add quotes to preserve the value.

Proposed fix
                 - name: TEST_SUITES_YAML
                   value: |-
                     - image: ${TEST_IMAGE}:${IMAGE_TAG}
-                      slackChannel: ${SLACK_CHANNEL}
+                      slackChannel: "${SLACK_CHANNEL}"

Apply the same fix to test/e2e/e2e-template.yml at the same lines.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: TEST_SUITES_YAML
value: |-
- image: ${TEST_IMAGE}:${IMAGE_TAG}
slackChannel: ${SLACK_CHANNEL}
- name: TEST_SUITES_YAML
value: |-
- image: ${TEST_IMAGE}:${IMAGE_TAG}
slackChannel: "${SLACK_CHANNEL}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@boilerplate/openshift/golang-osd-e2e/e2e-template.yml` around lines 98 - 101,
The TEST_SUITES_YAML block emits an unquoted slackChannel scalar which lets
values like `#channel` be treated as a YAML comment and lost; update the
TEST_SUITES_YAML value so slackChannel uses a quoted interpolation (i.e. wrap
${SLACK_CHANNEL} in quotes) to preserve literal channels, and apply the
identical change to the e2e-template.yml copy; ensure you only modify the
slackChannel line (leave TEST_IMAGE and IMAGE_TAG interpolation untouched).

Comment on lines +662 to +668
# Convert the selector back to YAML format with proper indentation
selector = spec["clusterDeploymentSelector"]
# Dump with proper indentation for inserting into template
selector_yaml = yaml.dump(selector, default_flow_style=False, sort_keys=False)
# Indent each line by 6 spaces (to match template indentation)
indented_lines = [" " + line for line in selector_yaml.splitlines()]
return "\n".join(indented_lines)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix the selector indentation before inserting it.

With six leading spaces here, the rendered YAML becomes clusterDeploymentSelector: null and puts matchLabels / matchExpressions beside it. Custom selectors are therefore not actually applied.

Suggested fix
-                # Indent each line by 6 spaces (to match template indentation)
-                indented_lines = ["      " + line for line in selector_yaml.splitlines()]
+                # Indent each line so it stays nested under `clusterDeploymentSelector`
+                indented_lines = ["        " + line for line in selector_yaml.splitlines()]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Convert the selector back to YAML format with proper indentation
selector = spec["clusterDeploymentSelector"]
# Dump with proper indentation for inserting into template
selector_yaml = yaml.dump(selector, default_flow_style=False, sort_keys=False)
# Indent each line by 6 spaces (to match template indentation)
indented_lines = [" " + line for line in selector_yaml.splitlines()]
return "\n".join(indented_lines)
# Convert the selector back to YAML format with proper indentation
selector = spec["clusterDeploymentSelector"]
# Dump with proper indentation for inserting into template
selector_yaml = yaml.dump(selector, default_flow_style=False, sort_keys=False)
# Indent each line so it stays nested under `clusterDeploymentSelector`
indented_lines = [" " + line for line in selector_yaml.splitlines()]
return "\n".join(indented_lines)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@boilerplate/openshift/golang-osd-operator/olm_pko_migration.py` around lines
662 - 668, The selector YAML is being indented by 6 spaces (indented_lines = [" 
" + line ...]) which mis-nests the block and produces
`clusterDeploymentSelector: null`; update the indentation so the dumped selector
lines align as a proper YAML block under the clusterDeploymentSelector key
(e.g., indent by 8 spaces or compute indentation to match the template) by
changing the prefix used when building indented_lines (reference selector_yaml
and indented_lines) so the selector's top-level keys
(matchLabels/matchExpressions) appear nested under clusterDeploymentSelector.

Comment on lines +698 to +701
print(f"Please review this file and ensure the deployment targets match your expectation")
else:
print("⚠ Using default clusterDeploymentSelector (hack/olm-registry/olm-artifacts-template.yaml not found)")
print(f"Please review this file and ensure the deployment targets match your expectation")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if the file exists and read lines 698-701
cat -n boilerplate/openshift/golang-osd-operator/olm_pko_migration.py | sed -n '695,705p'

Repository: openshift/certman-operator

Length of output: 744


🌐 Web query:

Ruff F541 rule unused f-string prefix

💡 Result:

The Ruff rule F541, named "f-string-missing-placeholders" (commonly reported as "f-string without any placeholders" or "unused f-string prefix"), detects f-strings that do not contain any placeholder expressions like {var}. It flags cases where the 'f' prefix is unnecessary, recommending a regular string literal instead to avoid confusion. Example violation: f"Hello, world!" Suggested fix: "Hello, world!" This rule is derived from Pyflakes, added in Ruff v0.0.18, and is automatically fixable. It considers implicit string concatenations: flags f-strings without placeholders even if concatenated with others that have them (matching Pyflakes behavior, fixed in 2024 via PR #10886). Format specifiers (e.g., f"{v:0.2f}") are not flagged as false positives. Official documentation: https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/ Enabled by default under Pyflakes (F) rules.

Citations:


Remove the unnecessary f prefixes from print statements.

Lines 698 and 701 both have f-string prefixes but don't contain any variable interpolation. Ruff F541 flags f-strings without placeholders as these can be regular string literals instead.

Suggested fix
-        print(f"Please review this file and ensure the deployment targets match your expectation")
+        print("Please review this file and ensure the deployment targets match your expectation")
         else:
         print("⚠ Using default clusterDeploymentSelector (hack/olm-registry/olm-artifacts-template.yaml not found)")
-        print(f"Please review this file and ensure the deployment targets match your expectation")
+        print("Please review this file and ensure the deployment targets match your expectation")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(f"Please review this file and ensure the deployment targets match your expectation")
else:
print("⚠ Using default clusterDeploymentSelector (hack/olm-registry/olm-artifacts-template.yaml not found)")
print(f"Please review this file and ensure the deployment targets match your expectation")
print("Please review this file and ensure the deployment targets match your expectation")
else:
print("⚠ Using default clusterDeploymentSelector (hack/olm-registry/olm-artifacts-template.yaml not found)")
print("Please review this file and ensure the deployment targets match your expectation")
🧰 Tools
🪛 Ruff (0.15.6)

[error] 698-698: f-string without any placeholders

Remove extraneous f prefix

(F541)


[error] 701-701: f-string without any placeholders

Remove extraneous f prefix

(F541)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@boilerplate/openshift/golang-osd-operator/olm_pko_migration.py` around lines
698 - 701, Remove the unnecessary f-string prefixes on the two print calls in
the conditional block (the lines printing "Please review this file and ensure
the deployment targets match your expectation" and the preceding warning line)
by replacing f"...” with regular string literals "..."; locate the print
statements in olm_pko_migration.py (the block that prints the default
clusterDeploymentSelector warning) and remove the leading "f" characters so Ruff
F541 is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant