Skip to content

fix(utilities): soft delete removed pubcode entries again - #654

Merged
DerekRoberts merged 2 commits into
mainfrom
fix/remove-deleted-pubcode-entries
Oct 6, 2026
Merged

DerekRoberts merged 2 commits into
mainfrom
fix/remove-deleted-pubcode-entries

Conversation

@DerekRoberts

@DerekRoberts DerekRoberts commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Entries whose bcgovpubcode.yml was removed from their repo stay visible in the catalogue.

Soft delete already exists (is_deleted, DELETE /api/pub-code/:repo_name, and the daily soft-delete-removed-pubcodes job), but since the chart moved to an Ingress in #561 every scheduled job has failed at oc get route/pubcode-api. That includes the crawler, so new and updated pubcodes aren't loaded either.

Changes

  • scheduled.yml: read the API host from ingress/pubcode-api for the crawler and the soft-delete job.
  • utilities/remove-deleted-pubcode:
    • A repo counts as removed only when both .yml and .yaml return 404. Any other GitHub error keeps the entry.
    • Fails fast: missing API_KEY/API_URL, a failed list fetch, or any failed delete now exits non-zero. Before, these were logged and ignored.
    • Lists entries from API_URL instead of a hardcoded prod URL.
  • Unit tests (node --test, no new dependencies), run in PR CI as Utility Tests and required by Results.

Notes

  • If a repo adds its file back, the next crawl clears is_deleted again: the crawler's findOneAndReplace applies the schema default.
  • The new lookup was checked against the chart's rendered Ingress (pubcode-api.apps.silver.devops.gov.bc.ca). It will be proven by the first scheduled run after merge.
  • Not in scope: validate-ministry-list also fails daily, with an @actions/core default-import error in schema/script.

Closes #256


Thanks for the PR!

Deployments, as required, will be available below:

Please create PRs in draft mode. Mark as ready to enable:

After merge, new images are deployed in:

Scheduled jobs look up the API host with `oc get route/pubcode-api`,
but since the chart switched to an Ingress (#561) that route no longer
exists, so the crawler and the soft-delete job have failed every day.
Read the host from `ingress/pubcode-api` instead.

The soft-delete utility now fails fast: missing API_KEY/API_URL, a
failed list fetch, or any failed delete exits non-zero instead of being
logged and ignored. Only a 404 for both bcgovpubcode.yml and .yaml marks
a repo as removed; other GitHub errors keep the entry.

Add node:test unit tests for the removal logic and run them in PR CI.

Closes #256
Copilot AI balanced review requested due to automatic review settings October 3, 2026 15:53
@DerekRoberts DerekRoberts self-assigned this Oct 3, 2026
@DerekRoberts DerekRoberts moved this to Active in DevOps (NR) Oct 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Static review found no blocking issues in the cleanup logic, Ingress lookup, or CI integration; tests were not executed.

Review effort: Balanced
Findings: None

What changed in this PR

Restores scheduled catalogue updates and soft deletion of entries whose pubcode files have been removed.

Changes:

  • Uses the API Ingress host for scheduled jobs.
  • Preserves entries on GitHub errors other than 404 and reports configuration/API failures.
  • Adds utility tests required by PR CI.
File Description
utilities/​remove-deleted-pubcode/​package.json Enables Node’s test runner.
utilities/​remove-deleted-pubcode/​index.test.js Tests removal detection and delete handling.
utilities/​remove-deleted-pubcode/​index.js Refactors cleanup and propagates failures.
.github/​workflows/​scheduled.yml Replaces Route lookups with Ingress lookups.
.github/​workflows/​pr-open.yml Adds utility tests to the required Results check.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mishraomp mishraomp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

city 🚀

@DerekRoberts
DerekRoberts merged commit f1e4555 into main Oct 6, 2026
13 checks passed
@DerekRoberts
DerekRoberts deleted the fix/remove-deleted-pubcode-entries branch October 6, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Remove bcgovpubcode entries from DB if it is removed from repo.

3 participants