Skip to content

Handle anonymous package_search context in CKAN action chain - #292

Draft
nicolas-becker with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-build-and-scan-image-job
Draft

Handle anonymous package_search context in CKAN action chain#292
nicolas-becker with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-build-and-scan-image-job

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown

The CI job Build and Scan Image with Integration Tests was failing due to frontend private-dataset navigation indirectly triggering backend package_search errors. The root cause was an AttributeError in the chained action context setup when requests were anonymous.

  • Root cause

    • get_privileged_context() assumed tk.current_user.id always exists.
    • Anonymous requests (AnonymousUser) lack id, causing package_search facet post-processing to throw and return 500s.
  • Change made

    • Updated privileged context construction in src/ckanext-tdc/ckanext/tdc/logic/action.py to safely read user id for both authenticated and anonymous requests.
    • Behavior remains unchanged for authenticated users; anonymous requests now pass user=None instead of raising.
  • Resulting behavior

    • Chained package_search post-processing no longer crashes on anonymous traffic.
    • Prevents backend 500s caused by facet display-name enrichment on anonymous requests.
def get_privileged_context():
    current_user_id = getattr(tk.current_user, "id", None)
    return {
        "ignore_auth": True,
        "user": current_user_id,
    }

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
tdc-data-portal Ignored Ignored Preview Aug 12, 2026 5:12pm

Request Review

Co-authored-by: nicolas-becker <56161155+nicolas-becker@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job Build and Scan Image with Integration Tests Handle anonymous package_search context in CKAN action chain Aug 12, 2026
Copilot AI requested a review from nicolas-becker August 12, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants