fix: include child table metadata in get_doctype_info#193
Merged
Conversation
get_doctype_info previously returned only top-level fields, so callers hitting create_document for a parent doctype (Sales Order, Purchase Order, etc.) had no way to discover the child DocType's own fields and ended up creating the parent with empty child tables. create_document's own description already instructs the model to call get_doctype_info first, so the gap left the workflow broken. Add a child_tables list to the response — one entry per Table / Table MultiSelect field — including each child DocType's full field metadata (same shape as the parent fields array). Callers now have everything they need in a single tool call. Also fix is_single, which was reading meta.istable (child-table flag) instead of meta.issingle, and add a separate is_child_table key so the two concepts stop being conflated. Tests: regression guard asserting `User` exposes its `roles` child table with recursive field metadata, plus a single-vs-child-table distinguishing test against `System Settings` and `Has Role`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_doctype_inforeturned only top-level fields, so callers hittingcreate_documentfor a parent doctype (Sales Order, Purchase Order, etc.) had no way to discover the child DocType's own fields — and ended up creating the parent with empty child tables.create_document's own description (create_document.py:44) already tells the model "First use get_doctype_info to understand the DocType structure, identify required fields and child tables" — so the gap left the documented workflow broken.This PR:
child_tableslist to the response — one entry perTable/Table MultiSelectfield, including each child DocType's full field metadata (same shape as the parentfieldsarray). Callers now have everything they need in a single tool call.is_single, which was readingmeta.istable(child-table flag) instead ofmeta.issingle. Adds a separateis_child_tablekey so the two concepts stop being conflated.Response shape (additions only)
{ "is_single": false, "is_child_table": false, "child_tables": [ { "fieldname": "items", "label": "Items", "fieldtype": "Table", "options": "Sales Order Item", "reqd": 1, "fields": [ {"fieldname": "item_code", "fieldtype": "Link", "options": "Item", "reqd": 1, ...}, {"fieldname": "qty", "fieldtype": "Float", "reqd": 1, ...}, ... ] }, ... ] }Type of Change
Related Issues
Fixes #192
Test Plan
test_get_doctype_metadata_includes_child_tables: assertsUser.rolesis present inchild_tableswith recursive field metadata (rolefield exposed inside).test_get_doctype_metadata_distinguishes_single_from_child_table:System Settingsreturnsis_single=True, is_child_table=False;Has Rolereturnsis_single=False, is_child_table=True.bench --site <site> run-tests --app frappe_assistant_core --module frappe_assistant_core.tests.test_metadata_tools— 21 tests pass (15 pre-existing placeholders skipped).Sales Order: 6 child tables returned with full nested field metadata.Checklist
developbranch (notmain)