Commit Graph

73629 Commits

Author SHA1 Message Date
Fredrik Adelöw fbae43b4d0 catalog-backend: use index-only GROUP BY + LATERAL for dedup
Replace the window-function full-table scan with a two-phase approach
that leverages search_key_value_entity_idx (key, value, entity_id):

  Phase 1: GROUP BY entity_id, key, value with HAVING COUNT(*) > 1
           resolves as a pure index-only scan (Heap Fetches: 0).
           Stores only the duplicate groups in a temp table (~8s for
           a 14M-row table with 700k dupes).

  Phase 2: CROSS JOIN LATERAL back into search using the same covering
           index (Nested Loop + Index Scan). row_number() runs per-group
           over the 2-3 matching rows, so there is no global external
           sort. A single DELETE removes all extras in one statement
           (~16s).

NULL values get a separate UNION ALL arm so the index equality
condition stays usable (value = NULL is always false in SQL).

Benchmarked on a 14.4M-row production-like staging master with
700k injected duplicates, post-VACUUM:
  Old (seq scan + external merge sort): ~101s
  New (index-only + index scan):         ~25s  (~4× faster)

Clean second run (no dupes, fast path skips dedup): <50ms.

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 18:27:11 +02:00
Fredrik Adelöw c7706249ba fix(catalog-backend): use explicit null sentinel in dedup keys and add buildEntitySearch dedup tests
Use `=== null ? '\x01' : value` instead of `?? ''` in both buildEntitySearch
and syncSearchRows dedup maps, so that null and empty-string values are
treated as distinct keys. In theory an entity could produce both value=null
and value='' for the same key (e.g. spec.foo: [null, '']), and the old
encoding would silently drop one of the two distinct rows.

Also adds two focused unit tests to buildEntitySearch.test.ts: one covering
deduplication of duplicate array values (e.g. tags: ['java', 'java', 'Java']),
and one confirming that null and empty-string are kept as separate rows.

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 17:07:49 +02:00
Fredrik Adelöw 36514a23d6 fix(catalog-backend): use two-phase dedup in search migration to avoid full-table re-scans
The original single-pass CTE window-function DELETE re-scanned every row
on each invocation — including the idempotent "nothing to do" case which
took over 4 minutes on a 14 M-row table, and timed out the DB proxy on
the dirty case (~217 s for 722 k duplicates).

Replace it with two improvements:

1. Fast path: if the UNIQUE index already exists and is valid, skip dedup
   entirely. A valid unique index is a proof-of-no-duplicates. This makes
   migration startup essentially free for installations that prepare the
   index manually beforehand (as documented in the migration comment).

2. Two-phase dedup when dedup is needed: Phase 1 does one full-table scan
   to collect all duplicate ctids into a temp table (~60 s on 14 M rows).
   Phase 2 drains that temp table in 10 k-row batches via cheap ctid
   lookups with no further full-table scans (~5 s for 722 k rows). Total
   ~65 s dirty vs >217 s+ before, and ~35 ms clean vs 4+ minutes before.

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 16:52:44 +02:00
Fredrik Adelöw f503fc935b fix(catalog-backend): scope pg_class lookups to relkind='i' in migration helpers
Prevents a false match if any non-index object (table, sequence, view)
shares a name with one of the search indices.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 13:42:06 +02:00
Fredrik Adelöw 63036124cc test(catalog-backend): add ON CONFLICT DO UPDATE coverage for original_value overwrite
Verifies that a conflicting insert with a different original_value casing
updates the stored value, and documents that DO UPDATE requires explicit
conflict columns unlike DO NOTHING.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 13:33:01 +02:00
Fredrik Adelöw 930c575e58 test(catalog-backend): simplify onConflict().ignore() and add UNIQUE constraint test
Remove the explicit column list from .onConflict() calls in test setup —
ON CONFLICT DO NOTHING without a target is equivalent since (entity_id,
key, value) is the only unique constraint on the search table.

Add a dedicated test in syncSearchRows that directly inserts a duplicate
row and verifies it is silently rejected via the UNIQUE constraint.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 12:55:10 +02:00
Fredrik Adelöw bb6c46adc0 fix(catalog-backend): create replacement indices before dropping in down migration
Avoids a window with no coverage on (key, value) during rollback.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 12:50:02 +02:00
Fredrik Adelöw c8efd9dda5 clarify death loop risk in migration comments and changeset
Be explicit that interrupted index builds do not leave partial progress —
each retry starts from scratch. On large tables with short liveness
probe timeouts this repeats indefinitely. Recommend running the SQL
commands manually before deploying.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
2026-05-10 19:16:32 +02:00
Fredrik Adelöw 27d2d3f0a2 fix down migration + update SQL report
The down migration now restores the previous index state (drops new
indices, recreates the old search_key_value_idx and
search_key_original_value_idx). Updated the SQL report to reflect the
new index set.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
2026-05-10 14:21:19 +02:00
Fredrik Adelöw 7445f0f5bc draft(catalog-backend): search table dedup, covering indices, UNIQUE constraint
Single knex migration that cleans up duplicate search rows and creates
covering indices including a UNIQUE constraint on (entity_id, key, value).
Each step is idempotent and handles INVALID indices from interrupted runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
2026-05-10 14:16:03 +02:00
Andre Wanlin 044ba27248 Merge pull request #33884 from backstage/dependabot/npm_and_yarn/microsite/follow-redirects-1.16.0
chore(deps): bump follow-redirects from 1.15.6 to 1.16.0 in /microsite
2026-05-08 14:17:43 -05:00
Andre Wanlin a44f28972a Merge pull request #34141 from backstage/renovate/snyk-actions-digest
chore(deps): update snyk/actions digest to 9cf6ca7
2026-05-08 14:08:36 -05:00
Andre Wanlin 3e4d49db23 Merge pull request #34060 from raphaeltorquat0/fix/issue-32925
docs(techdocs): fix incorrect S3 permission in AWS configuration
2026-05-08 14:07:57 -05:00
Andre Wanlin d45038ebde Merge pull request #34062 from backstage/dependabot/npm_and_yarn/microsite/postcss-8.5.10
chore(deps): Bump postcss from 8.5.6 to 8.5.10 in /microsite
2026-05-08 14:07:17 -05:00
Andre Wanlin 87ff9ee4e3 Merge pull request #33645 from backstage/renovate/github-codeql-action-4.x
chore(deps): update github/codeql-action action to v4.35.4
2026-05-08 14:06:39 -05:00
Andre Wanlin cd02b9e99b Merge pull request #33635 from backstage/dependabot/npm_and_yarn/brace-expansion-1.1.13
build(deps): bump brace-expansion from 1.1.12 to 1.1.13
2026-05-08 14:06:15 -05:00
Andre Wanlin 1b046f6c6e Merge pull request #33634 from backstage/dependabot/npm_and_yarn/microsite/brace-expansion-1.1.13
build(deps): bump brace-expansion from 1.1.12 to 1.1.13 in /microsite
2026-05-08 14:06:03 -05:00
Andre Wanlin df2a5f8de1 Merge pull request #34120 from backstage/dependabot/npm_and_yarn/vm2-3.11.2
build(deps): bump vm2 from 3.10.3 to 3.11.2
2026-05-08 14:03:24 -05:00
Andre Wanlin 47f7e459bb Merge pull request #34094 from leboncoin/docs-style-guide-format-issue
docs(contribute): correct format issue in doc-style-guide.md
2026-05-08 14:02:28 -05:00
Andre Wanlin 5f8ff96fe0 Merge pull request #33545 from backstage/sennyeya/deployment-guide
docs: add deployment golden path guide
2026-05-08 14:01:59 -05:00
Andre Wanlin 254d2b9b5c Merge pull request #33793 from backstage/dependabot/npm_and_yarn/hono/node-server-1.19.13
chore(deps): bump @hono/node-server from 1.19.10 to 1.19.13
2026-05-08 14:01:34 -05:00
Andre Wanlin ea7d8ac8e9 Merge pull request #33489 from jdgranberry/correct-rum-config-syntax
docs: correct syntax for configuring RUM instrumentation
2026-05-08 13:59:05 -05:00
Andre Wanlin e344fe40cb Merge pull request #34116 from drodil/fix_mui_to_bui_skill
docs(mui-to-bui): fix mangled jsx examples
2026-05-08 13:33:47 -05:00
Eva Gustavsson 41b65b190e fix: Correct faulty link to techdocs-cli (#34091)
The link to Github repository of techdocs-cli was
faulty. This commit corrects the link in the
documentation.

Signed-off-by: evhnn29 <eva.gustavsson@t-online.de>
2026-05-08 10:22:56 -04:00
Fredrik Adelöw 95f31b18ec Merge pull request #34160 from backstage/freben/catalog-metrics-cache
fix(catalog-backend): cache and cheapen catalog_entities_count metric
2026-05-08 14:51:08 +03:00
Fredrik Adelöw 594de037f1 Merge pull request #34158 from backstage/freben/facets-inner-join
fix(catalog-backend): use INNER JOIN for filtered entity facets
2026-05-08 14:49:55 +03:00
Fredrik Adelöw 8f7f591c46 coalesce overlapping callers via single-flight in-flight promise
Hold a shared promise rather than just a resolved value. Concurrent
callers awaiting a fresh count get the same in-flight promise back, so
the underlying query is never overlapped by a duplicate. The TTL is now
the minimum gap between the resolution of one query and the start of
the next, rather than a hard bound on cache age.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
2026-05-08 11:55:26 +02:00
Fredrik Adelöw ccbad9d892 fix(catalog-backend): cache and cheapen catalog_entities_count metric
The legacy Prometheus and OpenTelemetry observable gauges previously each
ran the per-kind count query against the search table on every metrics
scrape. With multiple pods and short scrape intervals, identical
sequential scans piled up faster than they completed, contending for
buffers in the database.

Extract a shared helper that wraps a 30-second TTL cache around a single
query, and have both gauges read from it. The query itself moves from
the (large) search table to final_entities, parsing kind out of
entity_ref via per-engine substring functions. The emitted labels and
values are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
2026-05-08 11:48:58 +02:00
Fredrik Adelöw 3f55b73e32 fix(catalog-backend): use INNER JOIN for filtered entity facets
Replace the `WHERE search.entity_id IN (...)` form with an INNER JOIN
against the filtered final_entities subquery in DefaultEntitiesCatalog#facets.
Results are unchanged; the planner gets more freedom to pick cheaper plans,
which on large catalogs leads to substantial speedups (1.2× to 7×+ in
adversarial testing on a ~13.8M-row search table) and avoids the
materialize-then-spill pattern of the IN form.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
2026-05-08 11:17:08 +02:00
renovate[bot] 2e435d8e88 Update github/codeql-action action to v4.35.4
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-07 16:26:59 +00:00
Johan Persson 4bb649d511 fix(ui): prevent selection checkboxes from creating phantom scroll height
Add `position: relative` to `.bui-Table` so it becomes the containing
block for react-aria's absolutely positioned hidden checkbox inputs.

Without this, the inputs position themselves relative to a distant
ancestor, extending its scrollable area and creating phantom scroll
height.

Signed-off-by: Johan Persson <johanopersson@gmail.com>
2026-05-07 16:39:02 +02:00
Fredrik Adelöw 213c6807d9 Merge pull request #33991 from jtbry/master
fix(SecureTemplater): return dispose function to clean up secure temp…
2026-05-07 17:15:23 +03:00
Fredrik Adelöw 90d9e05133 Merge pull request #34149 from hudsonb/bhudson/aws-wif-token-file
feat(integration-aws-node): add per-account webIdentityTokenFile config
2026-05-07 16:28:12 +03:00
Fredrik Adelöw 52dd22b436 Merge pull request #34150 from backstage/rugvip/app-routes-param-redirects
plugin-app: substitute path params in app/routes redirect targets
2026-05-07 15:33:19 +03:00
Fredrik Adelöw 5ebd1a14a0 plugin-app: fix param substitution to use word boundary
Use a word-boundary regex (:name\b) instead of a plain string replace
so that a shorter param like :a doesn't corrupt a longer param :ab
when both are present in the route.

Signed-off-by: Patrik Oldsberg <rugvip@backstage.io>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-07 14:03:07 +02:00
Fredrik Adelöw a3458208a5 plugin-app: substitute path params in app/routes redirect targets
The app/routes redirect config now performs the same :param and *
substitution that the legacy Redirect component did before navigating.
Named params captured by the `from` pattern are replaced in the `to`
string, enabling redirects like /users/:userId → /profile/:userId and
/old-docs → /docs/* (with splat forwarding).

Adds tests for both named-param and splat substitution.

Signed-off-by: Patrik Oldsberg <rugvip@backstage.io>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-07 13:57:23 +02:00
Brian Hudson 8df06ec2bc feat(integration-aws-node): add per-account webIdentityTokenFile config
Adds an optional `webIdentityTokenFile` field to
`AwsIntegrationAccountConfig` and `AwsIntegrationDefaultAccountConfig`.
When set on a per-account config along with a `roleName` and no static
credentials, `DefaultAwsCredentialsManager` now retrieves credentials
by calling `AssumeRoleWithWebIdentity` directly using the file's
contents as the web identity token (via `fromTokenFile`). The token
file is re-read on each refresh, so an external process can rotate it
in place — the same mechanism EKS IRSA uses, where the kubelet rotates
a projected service account token at the path identified by
`AWS_WEB_IDENTITY_TOKEN_FILE`.

This unlocks multi-account `AssumeRoleWithWebIdentity` for backends
running outside AWS (GKE, Cloud Run, Vault sidecars, etc.) without
requiring every plugin to construct a custom `AwsCredentialsManager`.
Existing call sites and configurations are unaffected — the new path
is opt-in via the new optional field.

Validator rejects:

- `webIdentityTokenFile` combined with static credentials
  (`accessKeyId`/`secretAccessKey`) on the same account
- `webIdentityTokenFile` combined with `profile` on the same account
- `webIdentityTokenFile` without a `roleName` (matches the existing
  precedent for `externalId`/`region`/`partition` without `roleName`)
- `webIdentityTokenFile` combined with `externalId` (the STS
  `AssumeRoleWithWebIdentity` API does not accept an external ID)

Same rules apply at the `accountDefaults` level. The `!config.accessKeyId`
guard in `getSdkCredentialProvider` is defensive — it protects callers
that build an `AwsIntegrationAccountConfig` directly without going
through `readAwsIntegrationConfig`. In that case we fall through to the
existing static-creds AssumeRole path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Brian Hudson <brian.r.hudson@gmail.com>
2026-05-07 07:43:47 -04:00
Andre Wanlin 11de61064c Merge pull request #34054 from backstage/analytics/instrumentation-skill
[Analytics] Instrumentation Agent Skill
2026-05-06 14:55:04 -05:00
Andre Wanlin fe697792c5 Merge pull request #34105 from awanlin/topic/non-breaking-typos
Fixes for non-breaking typos and typos configuration
2026-05-06 13:44:11 -05:00
Justin Bryant 964bc8694f fix: run prettier
Signed-off-by: Justin Bryant <justintbry@gmail.com>
2026-05-06 10:04:32 -04:00
Justin Bryant 4bcbd8245b Merge branch 'master' into master
Signed-off-by: Justin Bryant <justintbry@gmail.com>
2026-05-06 09:49:24 -04:00
Rickard Dybeck e68cb8ac0f feat(kubernetes-react): add optional getClusters() cache to KubernetesBackendClient (#34136)
fix(kubernetes-react): coalesce concurrent getClusters() fetches and validate TTL input

Signed-off-by: Rickard Dybeck <dybeck@spotify.com>
2026-05-06 09:16:24 -04:00
renovate[bot] 2f54d56a7c Update snyk/actions digest to 9cf6ca7
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-05-06 13:03:29 +00:00
backstage-goalie[bot] 548a5558f5 Merge pull request #34126 from backstage/renovate/npm-axios-vulnerability
Update dependency axios to v1.15.2 [SECURITY]
2026-05-06 12:55:51 +00:00
backstage-goalie[bot] ad7eaee232 Merge pull request #34064 from backstage/renovate/npm-postcss-vulnerability
Update dependency postcss to v8.5.10 [SECURITY]
2026-05-06 12:55:46 +00:00
Fredrik Adelöw a590d4ad96 Merge pull request #34130 from backstage/codex/turtle395-improve-mcp-auth-dialog
Show MCP client metadata in auth consent dialog
2026-05-06 14:56:34 +03:00
Djam 9d6edc0622 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Djam <rdjamaile@gmail.com>
2026-05-06 13:02:43 +02:00
djamaile 4f62755eed feat(auth): TURTLE-395: show MCP client metadata
Signed-off-by: djamaile <rdjamaile@gail.com>
2026-05-06 11:19:17 +02:00
Fredrik Adelöw d047c50c4b Merge pull request #34102 from backstage/changeset-release/master
Version Packages (next)
2026-05-05 19:37:23 +03:00
github-actions[bot] b0bc1e5cc9 Version Packages (next) 2026-05-05 14:57:07 +00:00