Skip to content
This repository was archived by the owner on Jul 3, 2026. It is now read-only.
This repository was archived by the owner on Jul 3, 2026. It is now read-only.

Scheduled Job auto_delete_expired_perms fails due to permission check on field valid_until #609

Description

@nilpatel42

The scheduled job drive.api.permissions.auto_delete_expired_perms fails with a PermissionError when running.

Traceback shows that frappe.get_list is used with a filter on the field valid_until, but this field is not included in the permitted fields for the Drive Permission doctype.

Error:
PermissionError: You do not have permission to access field: Drive Permission.valid_until

Relevant code:

expired_documents = frappe.get_list(
    "Drive Permission",
    filters=[
        ["valid_until", "is", "set"],
        ["valid_until", "<", current_date]
    ],
    fields=["name", "valid_until"]
)

Since this is a background scheduled job, it should either:

  • use frappe.get_all() to bypass permission checks, or
  • ensure the field valid_until is allowed for filtering.

This causes the scheduler to fail repeatedly.

Traceback (most recent call last):

File "apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py", line 156, in execute
    frappe.get_attr(self.method)()

File "apps/drive/drive/api/permissions.py", line 243, in auto_delete_expired_perms
    expired_documents = frappe.get_list(

File "apps/frappe/frappe/__init__.py", line 1362, in get_list
    return frappe.model.qb_query.DatabaseQuery(doctype).execute(*args, **kwargs)

File "apps/frappe/frappe/model/qb_query.py", line 203, in execute
    query = frappe.qb.get_query(**kwargs)

File "apps/frappe/frappe/query_builder/utils.py", line 65, in get_query
    return Engine().get_query(*args, **kwargs)

File "apps/frappe/frappe/database/query.py", line 292, in get_query
    self.apply_filters(filters)

File "apps/frappe/frappe/database/query.py", line 454, in apply_filters
    self.apply_list_filters(filters)

File "apps/frappe/frappe/database/query.py", line 502, in apply_list_filters
    self._apply_filter(field, value, operator)

File "apps/frappe/frappe/database/query.py", line 527, in _apply_filter
    criterion = self._build_criterion_for_simple_filter(field, value, operator)

File "apps/frappe/frappe/database/query.py", line 554, in _build_criterion_for_simple_filter
    _field = self._validate_and_prepare_filter_field(field)

File "apps/frappe/frappe/database/query.py", line 930, in _validate_and_prepare_filter_field
    self.check_filter_field_permission(target_doctype, target_fieldname)

File "apps/frappe/frappe/database/query.py", line 944, in check_filter_field_permission
    self._check_field_permission(doctype, fieldname, for_filtering=True)

File "apps/frappe/frappe/database/query.py", line 977, in _check_field_permission
    frappe.throw(

frappe.exceptions.PermissionError:
You do not have permission to access field:
Drive Permission.valid_until

Version:

Frappe version: frappe: 16.10.10
Drive app: drive: 0.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions