Skip to content

Conversation

@surajnarwade
Copy link
Contributor

@surajnarwade surajnarwade commented Dec 31, 2025

This PR solves this issue: #4259

Hey, I just made a Pull Request!

✔️ 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)
  • All your commits have a Signed-off-by line in the message. (more info)

@backstage-service backstage-service added the workspace/tech-insights Used to tag tech-insights workspace issues and pull requests label Dec 31, 2025
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Dec 31, 2025

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage-community/plugin-tech-insights-backend
  • @backstage-community/plugin-tech-insights-maturity-common
  • @backstage-community/plugin-tech-insights-maturity
  • @backstage-community/plugin-tech-insights-react
  • @backstage-community/plugin-tech-insights

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
app workspaces/tech-insights/packages/app none v0.0.11
backend workspaces/tech-insights/packages/backend none v0.0.11
@backstage-community/plugin-tech-insights-backend-module-jsonfc workspaces/tech-insights/plugins/tech-insights-backend-module-jsonfc patch v0.6.1
@backstage-community/plugin-tech-insights-backend workspaces/tech-insights/plugins/tech-insights-backend none v2.4.3
@backstage-community/plugin-tech-insights-common workspaces/tech-insights/plugins/tech-insights-common patch v0.7.1
@backstage-community/plugin-tech-insights-maturity-common workspaces/tech-insights/plugins/tech-insights-maturity-common none v0.3.1
@backstage-community/plugin-tech-insights-maturity workspaces/tech-insights/plugins/tech-insights-maturity none v0.5.0
@backstage-community/plugin-tech-insights-react workspaces/tech-insights/plugins/tech-insights-react none v1.2.1
@backstage-community/plugin-tech-insights workspaces/tech-insights/plugins/tech-insights none v0.6.2

@surajnarwade surajnarwade changed the title Feat checks filter tech-insights: ability to add filters on the checks Dec 31, 2025
@surajnarwade surajnarwade force-pushed the feat-checks-filter branch 2 times, most recently from cf031e1 to d16ac69 Compare December 31, 2025 12:29
@surajnarwade surajnarwade marked this pull request as ready for review December 31, 2025 12:30
@surajnarwade surajnarwade requested review from a team, Xantier and punkle as code owners December 31, 2025 12:30
@surajnarwade surajnarwade requested review from awanlin and removed request for a team December 31, 2025 12:30
Comment on lines 37 to 47
deps: {
config: coreServices.rootConfig,
logger: coreServices.logger,
discovery: coreServices.discovery,
techInsights: techInsightsFactCheckerFactoryExtensionPoint,
},
async init({ config, logger, techInsights }) {
async init({ config, logger, discovery, techInsights }) {
const catalogClient = new CatalogClient({ discoveryApi: discovery });
const factory = JsonRulesEngineFactCheckerFactory.fromConfig(config, {
logger,
catalogApi: catalogClient,
Copy link
Member

Choose a reason for hiding this comment

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

A better route is having the module define catalog as a dependency with catalogServiceRef from @backstage/plugin-catalog-node. This is the newer way of communicating with the catalog as it includes auth support. In this scenario, I think passing { credentials: await this.auth.getOwnServiceCredentials() } as the second argument to the catalog api calls would suffice.

deps: {
  config: coreServices.rootConfig,
  logger: coreServices.logger,
-  discovery: coreServices.discovery,
+ catalog: catalogServiceRef,
+ auth: coreServices.auth,
  techInsights: techInsightsFactCheckerFactoryExtensionPoint,
}

wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

That is referring to the ingestion and processing of entities in the catalog, known as EntityProvider and EntityProcessor. This factory class is neither a catalog provider or processor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah okay, now it make sense. sorry I misunderstood earlier. I now found the similar references:

I will update my code accordingly, thank you for the review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @kurtaking, once again, thank you for the review, I have updated as per your suggestion.

@surajnarwade surajnarwade requested a review from kurtaking January 2, 2026 10:30
surajnarwade and others added 11 commits January 4, 2026 15:46
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: surajnarwade <[email protected]>
Signed-off-by: Suraj Narwade <[email protected]>
Signed-off-by: Suraj Narwade <[email protected]>
private compareValues(
entityValue: any,
filterValue: string | symbol,
): boolean {

Choose a reason for hiding this comment

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

This feature looks great for scalar properties like kind, spec.type, spec.lifecycle, etc.
Our main use case is to drive check applicability off catalog tags, e.g.:

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: cloud-ui-common
  tags:
    - cloudui
    - angular
    - common

Ideally we’d configure a check like:

filter:
  metadata.tags:
    - cloudui
    - backend

If I’m reading the current compareValues logic correctly, get(entity, 'metadata.tags') returns a string[], and the comparison ends up being ['cloudui', 'angular', 'common'] === 'cloudui', so the filter never matches.

Would you be open to extending compareValues to treat array entity values as “contains any of these filter values”? For example:

    // If entityValue is an array, treat it as "contains" semantics               <--- Suggested addition
    if (Array.isArray(entityValue)) {
      return entityValue.some(ev => this.compareValues(ev, filterValue));
    }

    // Handle string comparison case-insensitively for kind, type, lifecycle, etc.
    // This provides a better user experience as these values are typically case-insensitive
    if (typeof entityValue === 'string' && typeof filterValue === 'string') {
      return entityValue.toLowerCase() === filterValue.toLowerCase();
    }

    // Handle symbol comparison (less common but supported for completeness)
    if (typeof filterValue === 'symbol') {
      return entityValue === filterValue;
    }

    // Default to strict equality for all other types (numbers, booleans, etc.)
    return entityValue === filterValue;

That would allow metadata.tags to scope checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @PatrickFrueh, thank you so much for the review. I will test out the code for tags as well and make any necessary changes 🙏

Copy link
Contributor Author

@surajnarwade surajnarwade Jan 7, 2026

Choose a reason for hiding this comment

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

@PatrickFrueh I have updated the PR with suggested changes and tested locally and it works 🎉

Choose a reason for hiding this comment

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

Thanks so much for the quick turnaround @surajnarwade. Really appreciate you testing this locally and incorporating the change. 🚀

Signed-off-by: surajnarwade <[email protected]>
Copy link

@PatrickFrueh PatrickFrueh left a comment

Choose a reason for hiding this comment

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

Solved from the tag-filtering use-case perspective. The changes in src/service/JsonRulesEngineFactChecker.ts:L181-184 correctly handle array values via contains semantics. LGTM 👍

Thanks again for the quick update!

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

Labels

workspace/tech-insights Used to tag tech-insights workspace issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants