Skip to content

fix(worker): resolve SQLAlchemy mapper error and missing app.current_…#14

Merged
yuzushi-dev merged 1 commit intomainfrom
chore/post-audit-p0-fixes
Apr 22, 2026
Merged

fix(worker): resolve SQLAlchemy mapper error and missing app.current_…#14
yuzushi-dev merged 1 commit intomainfrom
chore/post-audit-p0-fixes

Conversation

@yuzushi-dev
Copy link
Copy Markdown
Owner

…tenant GUC

Two bugs caused all document processing to fail since April 16:

  1. Chunk model not imported at runtime in tasks.py — only under TYPE_CHECKING, so SQLAlchemy could not resolve Document.chunks relationship after the deep singleton reset. Fixed by importing Chunk explicitly at module level.

  2. configure_worker_session() only set app.is_super_admin but not app.current_tenant. RLS policies require both GUCs to be set or any SELECT on tenant tables raises UndefinedObject 42704. Fixed by adding the current_tenant GUC set and passing tenant_id from the task.

feat(admin): add View Source link to document detail page (ZTD-1826)

Show a View Source button in the document header when metadata.source_url is present, linking to the original documentation page.

…tenant GUC

Two bugs caused all document processing to fail since April 16:

1. Chunk model not imported at runtime in tasks.py — only under TYPE_CHECKING,
   so SQLAlchemy could not resolve Document.chunks relationship after the deep
   singleton reset. Fixed by importing Chunk explicitly at module level.

2. configure_worker_session() only set app.is_super_admin but not
   app.current_tenant. RLS policies require both GUCs to be set or any
   SELECT on tenant tables raises UndefinedObject 42704. Fixed by adding
   the current_tenant GUC set and passing tenant_id from the task.

feat(admin): add View Source link to document detail page (ZTD-1826)

Show a View Source button in the document header when metadata.source_url
is present, linking to the original documentation page.
@yuzushi-dev yuzushi-dev merged commit 3ca962b into main Apr 22, 2026
3 of 4 checks passed
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.

1 participant