Merge pull request #32865 from ankush/check_link_value

fix: Assert type of link field values
This commit is contained in:
Ankush Menat 2025-06-10 10:22:00 +05:30 committed by GitHub
commit 49a11a0112
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 5 deletions

View file

@ -55,7 +55,6 @@ jobs:
timeout-minutes: 30
env:
NODE_ENV: "production"
PYTHONOPTIMIZE: 2
# noisy 3rd party library warnings
PYTHONWARNINGS: "module,ignore:::babel.messages.extract"
DB_ROOT_PASSWORD: db_root

View file

@ -44,7 +44,6 @@ jobs:
timeout-minutes: 30
env:
NODE_ENV: "production"
PYTHONOPTIMIZE: 2
# noisy 3rd party library warnings
PYTHONWARNINGS: "ignore"
DB_ROOT_PASSWORD: db_root
@ -92,7 +91,7 @@ jobs:
-x '${{ github.event.repository.name }}/public/dist/**' \
-x '${{ github.event.repository.name }}/public/js/lib/**' \
-x '**/*.bundle.js' --compact=false --in-place ${{ github.event.repository.name }}
- name: Site Setup
run: |
source ${GITHUB_WORKSPACE}/env/bin/activate
@ -102,7 +101,7 @@ jobs:
- uses: browser-actions/setup-chrome@latest
- run: |
echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV
- name: Run Tests
run: |
source ${GITHUB_WORKSPACE}/env/bin/activate

View file

@ -175,7 +175,7 @@ class TestRQJob(IntegrationTestCase):
# If this starts failing analyze memory usage using memray or some equivalent tool to find
# offending imports/function calls.
# Refer this PR: https://github.com/frappe/frappe/pull/21467
LAST_MEASURED_USAGE = 42
LAST_MEASURED_USAGE = 46
if frappe.conf.use_mysqlclient:
# TEMP: Add extra allowance for running two connectors, this should be rolled back before v16
LAST_MEASURED_USAGE += 2

View file

@ -22,6 +22,7 @@ from frappe.model.dynamic_links import invalidate_distinct_link_doctypes
from frappe.model.naming import set_new_name
from frappe.model.utils.link_count import notify_link_count
from frappe.modules import load_doctype_module
from frappe.types.docref import DocRef
from frappe.utils import (
cached_property,
cast_fieldtype,
@ -864,6 +865,10 @@ class BaseDocument:
if not docname:
continue
assert isinstance(docname, str | int | DocRef) or (
isinstance(docname, list | tuple | set) and len(docname) == 1
), f"Unexpected value for field {df.fieldname}: {docname}"
if df.fieldtype == "Link":
doctype = df.options
if not doctype:

View file

@ -207,6 +207,9 @@ class TestDocument(IntegrationTestCase):
self.assertEqual(frappe.db.get_value("User", d.name), d.name)
d.append("roles", {"role": ("Guest", "Administrator")})
self.assertRaises(AssertionError, d._validate_links)
def test_validate(self):
d = self.test_insert()
d.starts_on = "2014-01-01"