Skip to content

[Bug] Row documents missing collab logs with permissions errors on API access and export #8986

Closed

Description

@barnabywalters

Bug Description

⚠️ AI-Generated Bug Report - This issue was generated by GitHub Copilot AI based on investigation and analysis of the codebase. Please review thoroughly and validate findings independently.


Database row documents created via "open as page" are inaccessible via API and export, despite being editable and synced to other users in real-time. The issue manifests as missing collab logs and permissions errors when attempting to retrieve row document data, while the row metadata and flattened text content remain accessible.

Root Cause Analysis

Row documents are created as orphan views in the folder system, causing four architectural misalignments:

  1. Metadata Derivation vs. Persistence Mismatch - The document_id in row metadata is derived deterministically from the row ID rather than being explicitly stored, causing the system to assume documents exist even when the collab was never persisted.

  2. Orphan View Permission Model - Row documents created via ViewBackendService.createOrphanView() are not integrated with the folder hierarchy or permission system. When the API tries to retrieve them via QueryCollabParams, the server's permission checks fail because the orphan view isn't hierarchically connected to the database.

  3. Collab Creation Without Finalization - Unlike database rows which have explicit finalization via collab_builder.finalize(), row documents send collabs to server in a background task without guaranteeing completion before export/API queries.

  4. Inconsistent Export/API Loading - Document IDs always derive successfully from metadata, but actual collab loading fails silently or with permissions errors, returning partial results.

Evidence from Code Review

  • Orphan view creation: frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_document_bloc.dart line 93-110
  • Metadata derivation: frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs line 840-861
  • Background collab sync: frontend/rust-lib/flowy-document/src/manager.rs line 180-192
  • API permission check: frontend/rust-lib/flowy-server/src/af_cloud/impls/document.rs line 30-57
  • Export loading: frontend/rust-lib/flowy-core/src/deps_resolve/folder_deps/folder_deps_database_impl.rs line 78-157

How to Reproduce

  1. Create a new database and add a row
  2. Open the row as a page and add content to the document
  3. Wait for sync completion and close AppFlowy
  4. Try to export the database or query the row document via API
  5. Observe permissions error and missing collab log

Expected Behavior

When a user opens a row as a page and edits the document:

  • The document collab should be persisted and accessible via API and export
  • The collab structure should be consistent with the real-time sync that works for other users
  • API calls should return the complete collab log, not just flattened text
  • Permissions should be inherited from the parent database/row, not fail with access errors

Operating System

Linux, macOS, Windows (affects all platforms - this is a server/backend issue affecting any client)

AppFlowy Version(s)

Current main branch (commit 5cf3a36)

Screenshots

N/A - This is an API/export data structure issue, not a UI bug

Additional Context

Why Waiting Doesn't Help:
Testing showed that waiting for sync completion and closing the application before export does not resolve the issue. This confirms the root cause is not a timing/persistence issue but rather a permission/registration issue on the server.

Impact:

  • Users cannot reliably export databases containing rows with documents
  • Row documents are inaccessible via API despite being fully editable
  • Data may be lost if relying on API-based backup or integration
  • Inconsistent UX: edits sync to others but document collab is not accessible to requester

Suggested Fixes (Architecture Level):

  1. Establish proper parent-child relationships between row documents and their rows in the folder hierarchy
  2. Implement row-based permission checking for row document access in the server API
  3. Add explicit finalization for row documents similar to database rows
  4. Create server-side indexes for row documents linked to their parent rows
  5. Validate collab existence before returning document_id in row metadata

Additional Notes:

  • The issue does not occur with normal documents (outside database rows)
  • Real-time sync and collaboration work correctly, indicating the collab object is created
  • The flattened text extraction works, showing document metadata is stored
  • This appears to be a design limitation rather than a simple bug, as row documents are intentionally orphan views

Report generated by: GitHub Copilot AI
Analysis based on commit: 5cf3a36
Please validate all findings independently before taking action.

Activity

  1. barnabywalters commented on Sep 3, 2026

    @barnabywalters
    Author

    This issue came out of various investigations we were doing into difficulties getting rich structured data out of appflowy for documents stored in database rows. We did eventually get it to work so it could be that the problems proposed here are actually not relevant, and that it’s instead a documentation/API definition issue which makes this harder than it needs to be. At least from our point of view the issues raised here are no longer currently blocking us with our project, so feel free to deprioritize or disregard.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions