Skip to content

[Konflux] Fix Latest Releases not shown when applications field is omitted or uses wildcard patterns.#2873

Merged
rrosatti merged 4 commits intoredhat-developer:mainfrom
rrosatti:KFLUXUI-1230/fix-konflux-latest-releases-not-shown
Apr 28, 2026
Merged

[Konflux] Fix Latest Releases not shown when applications field is omitted or uses wildcard patterns.#2873
rrosatti merged 4 commits intoredhat-developer:mainfrom
rrosatti:KFLUXUI-1230/fix-konflux-latest-releases-not-shown

Conversation

@rrosatti
Copy link
Copy Markdown
Contributor

Hey, I just made a Pull Request!

Description

In this PR we're fixing a bug where the "Latest Releases" card (shown in Overview tab) was not showing any release when the applications field was omitted or used wildcard patterns.

Fixes https://redhat.atlassian.net/browse/KFLUXUI-1230

How to test it?

  • create a backstage entity/component in which the konflux-ci.dev/clusters either have an applications field that uses wildcard patterns or ommit the applications field. Example:
kind: Component
apiVersion: backstage.io/v1alpha1
metadata:
  name: component-1
  description: Component 1
  title: Component 1
  annotations:
    konflux-ci.dev/overview: 'true'
    konflux-ci.dev/konflux: 'true'
    konflux-ci.dev/ci: 'true'
    konflux-ci.dev/clusters: |
      - cluster: <your-cluster>
        namespace: <your-namespace>
spec:
  type: service
  lifecycle: experimental
  owner: user:guest
  • navigate to Overview tab
  • notice that now the Konflux Latest Releases UI component should show the latest release given your config

Visual references

Before:

konflux-plugin-latest-release-ISSUE.mov

After:

konflux-plugin-latest-release-FIX.mov

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

Move globToRegex and matchesApplicationPattern from konflux-backend
to konflux-common so both frontend and backend can reuse them.
…s wildcards

The frontend was requiring the applications field to be present and
non-empty, silently discarding configs when it was omitted. It was
also doing literal string matching instead of glob pattern matching.
Add changesets with the changes made for konflux and konflux-backend
plugins.
@rrosatti rrosatti self-assigned this Apr 22, 2026
@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge Bot commented Apr 22, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Missing fetch-all regression test 🐞 Bug ⚙ Maintainability
Description
getLatestRelease now treats an empty/omitted applications list as “match all”, but there are no
tests validating this integration behavior (including applications: undefined or ['*']). This
increases the risk of reintroducing the original “Latest Releases shows nothing” bug during future
refactors.
Code

workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/utils.ts[R44-59]

+  // get all application patterns from matching configs
+  const appPatterns = matchingConfigs.flatMap(
+    config => config.applications ?? [],
  );
+  const fetchesAll = appPatterns.length === 0 || appPatterns.includes('*');

  const filteredReleases = releases.filter(release => {
    const applicationName = getApplicationFromResource(release) || '';
+    const matchesApp =
+      fetchesAll || matchesApplicationPattern(applicationName, appPatterns);
    return (
      release.subcomponent?.name === subcomponent &&
-      appNames.has(applicationName) &&
+      matchesApp &&
      release.cluster.name === cluster &&
      release.metadata?.namespace === namespace
    );
Relevance

⭐⭐⭐ High

Konflux PRs add tests for new wildcard/omitted-apps behavior; missing integration coverage likely
flagged.

PR-#2752

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR introduces a new fetchesAll branch in getLatestRelease when the collected application
patterns are empty or include '*'. Existing unit tests for getLatestRelease only exercise exact
application lists (e.g., ['app1','app2']) and do not cover omitted/empty applications or the
special '*' handling. While matchesApplicationPattern is unit-tested (including glob patterns
and the fact that an empty patterns array returns false), the critical integration behavior is
implemented outside that helper and currently lacks coverage.

workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/utils.ts[36-60]
workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/tests/utils.test.ts[44-51]
workspaces/konflux/plugins/konflux-common/src/tests/patterns.test.ts[63-91]
workspaces/konflux/plugins/konflux/src/hooks/useEntitiesKonfluxConfig.ts[49-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`getLatestRelease` now has a behavior where an omitted/empty `applications` list (or `['*']`) should match all releases, but there are no regression tests to lock this behavior in.

### Issue Context
This PR fixes a user-visible bug where Latest Releases was empty when `applications` was omitted or used wildcard patterns. Pattern matching itself is unit-tested in `konflux-common`, but the “fetch all” behavior is implemented in `getLatestRelease` via `fetchesAll` and needs direct tests.

### Fix Focus Areas
- workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/utils.ts[36-60]
- workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/__tests__/utils.test.ts[36-120]
- workspaces/konflux/plugins/konflux/src/hooks/useEntitiesKonfluxConfig.ts[49-60]
- workspaces/konflux/plugins/konflux/src/hooks/__tests__/useEntitiesKonfluxConfig.test.tsx[114-143]

### Suggested test cases (add to existing suites)
- `getLatestRelease` returns a release when `subcomponentConfigs` contains `{ applications: [] }` (omitted apps scenario).
- `getLatestRelease` returns a release when `applications: ['*']`.
- `useEntitiesKonfluxConfig` returns a config with `applications: []` when the parsed YAML cluster config omits `applications`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app Bot commented Apr 22, 2026

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-konflux-backend workspaces/konflux/plugins/konflux-backend patch v0.1.6
@red-hat-developer-hub/backstage-plugin-konflux-common workspaces/konflux/plugins/konflux-common patch v0.1.6
@red-hat-developer-hub/backstage-plugin-konflux workspaces/konflux/plugins/konflux patch v0.1.6

@rhdh-qodo-merge
Copy link
Copy Markdown

Review Summary by Qodo

Fix Latest Releases display with omitted or wildcard applications

🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Move glob pattern matching utilities to shared common package
• Fix Latest Releases card not showing when applications field omitted
• Support wildcard patterns in application filtering logic
• Add comprehensive tests for pattern matching functionality
Diagram
flowchart LR
  A["konflux-backend<br/>kubernetes.ts"] -->|"remove duplicate<br/>pattern logic"| B["konflux-common<br/>patterns.ts"]
  B -->|"export utilities"| C["konflux-common<br/>index.ts"]
  C -->|"import<br/>matchesApplicationPattern"| D["konflux<br/>LatestReleasesList"]
  C -->|"import<br/>matchesApplicationPattern"| E["konflux-backend<br/>kubernetes.ts"]
  D -->|"handle omitted &<br/>wildcard patterns"| F["Latest Releases<br/>Display Fixed"]
Loading

Grey Divider

File Changes

1. workspaces/konflux/plugins/konflux-common/src/patterns.ts ✨ Enhancement +42/-0

Create shared pattern matching utilities

• New file containing globToRegex function to convert glob patterns to RegExp
• New file containing matchesApplicationPattern function for pattern matching
• Supports exact matches and wildcard patterns with * character
• Properly escapes regex special characters in patterns

workspaces/konflux/plugins/konflux-common/src/patterns.ts


2. workspaces/konflux/plugins/konflux-common/src/__tests__/patterns.test.ts 🧪 Tests +95/-0

Add pattern matching unit tests

• Comprehensive test suite for globToRegex function covering exact matches, prefix/suffix/contains
 wildcards
• Tests for matchesApplicationPattern with exact names, glob patterns, and mixed patterns
• Edge cases including empty patterns, case sensitivity, and special character escaping
• 95 lines of test coverage for pattern matching logic

workspaces/konflux/plugins/konflux-common/src/tests/patterns.test.ts


3. workspaces/konflux/plugins/konflux-common/src/index.ts ✨ Enhancement +2/-0

Export pattern matching utilities

• Export new globToRegex and matchesApplicationPattern functions
• Makes pattern utilities available to other packages in the workspace

workspaces/konflux/plugins/konflux-common/src/index.ts


View more (4)
4. workspaces/konflux/plugins/konflux-backend/src/helpers/kubernetes.ts Refactor +1/-22

Remove duplicate pattern matching code

• Remove duplicate globToRegex and matchesApplicationPattern implementations
• Import matchesApplicationPattern from konflux-common package
• Eliminates code duplication and centralizes pattern matching logic

workspaces/konflux/plugins/konflux-backend/src/helpers/kubernetes.ts


5. workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/utils.ts 🐞 Bug fix +8/-4

Fix Latest Releases filtering logic

• Import matchesApplicationPattern from konflux-common
• Change from Set-based exact matching to pattern-based matching
• Handle omitted applications field by defaulting to empty array
• Support wildcard patterns and treat empty/* patterns as fetch-all
• Fix bug where releases were not shown without explicit applications list

workspaces/konflux/plugins/konflux/src/components/List/LatestReleasesList/utils.ts


6. workspaces/konflux/plugins/konflux/src/hooks/useEntitiesKonfluxConfig.ts 🐞 Bug fix +2/-7

Allow optional applications field in config

• Remove requirement for applications field to be present and non-empty
• Allow configs with omitted applications field to be processed
• Default applications to empty array when not provided
• Simplify validation to only require cluster and namespace fields

workspaces/konflux/plugins/konflux/src/hooks/useEntitiesKonfluxConfig.ts


7. workspaces/konflux/.changeset/ready-clowns-juggle.md 📝 Documentation +7/-0

Add changeset for release notes

• Changeset documenting patch version bumps for three packages
• Describes fix for Latest Releases not showing with omitted or wildcard applications
• Notes Backstage dependency bump from 1.45.2 to 1.49.4

workspaces/konflux/.changeset/ready-clowns-juggle.md


Grey Divider

Qodo Logo

@rhdh-qodo-merge rhdh-qodo-merge Bot added enhancement New feature or request bug_fix Tests labels Apr 22, 2026
Run 'yarn build:api-reports:only' to update api references.
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@milantaky milantaky left a comment

Choose a reason for hiding this comment

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

Left a small nit, otherwise releases show as expected with no applications, pattern, and exact name:)


const sortedReleases = safeToSorted(filteredReleases, compareFn);

if (!sortedReleases?.length) return null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: I think this check isn't necessary since the length is checked on filteredReleases and the sort function doesn't remove any items :)

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.

good catch! in theory it does not need, but I did that check just to "shut up Typescript" :D

@rrosatti rrosatti merged commit 378b871 into redhat-developer:main Apr 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants