frappe-errors-clientscripts
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "frappe-errors-clientscripts" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-e287a0f132b253f2015dc7db8889aa8fd9c2a43aa9ebd2bd591696551b7cd670. Verify the upstream source and version against https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
For debugging and preventing errors in Frappe client scripts. Targets possible TypeError, frappe.call failures, async/await issues, cur_frm vs frm confusion, missing fields, child table access errors, timing issues, CSRF token errors, and frappe.call permission denied cases. Includes diagnostic flows, debugging tool tips, and keywords for v14/v15/v16.
Introduction source: third_party · Impertio-Studio · 2.0 Reference
SkillPi interpretation
- Tasks
- Cross-refs: `frappe-syntax-clientscripts` (syntax), `frappe-impl-clientscripts` (workflows), `frappe-errors-serverscripts` (server-side).
- Testing
- Not tested
Browse files
Frontmatter
name: frappe-errors-clientscripts
description: >
Use when debugging or preventing errors in Frappe Client Scripts.
Prevents TypeError, frappe.call failures, async/await mistakes,
cur_frm vs frm confusion, field not found, child table access errors,
timing issues, CSRF token errors, and permission denied on frappe.call.
Covers error diagnosis flowchart and debug tools for v14/v15/v16.
Keywords: client script error, TypeError, frappe.call, async await,, Cannot read properties of undefined, TypeError, browser console error, script not running, form not updating.
cur_frm, field not found, child table, CSRF, permission denied.
license: MIT
compatibility: "Claude Code, Claude.ai Projects, Claude API. Frappe v14-v16."
metadata:
author: OpenAEC-Foundation
version: "2.0"Client Script Errors — Diagnosis and Resolution
Cross-refs: frappe-syntax-clientscripts (syntax), frappe-impl-clientscripts (workflows), frappe-errors-serverscripts (server-side).
Error Diagnosis Flowchart
ERROR IN CLIENT SCRIPT
│
├─► TypeError: Cannot read properties of undefined
│ ├─► "frm.doc.fieldname" → Field does not exist on DocType
│ ├─► "r.message.value" → Server returned null/error
│ └─► "row.fieldname" in child table → Row not fetched correctly
│
├─► frappe.call fails silently
│ ├─► Missing error callback → Add error handler
│ ├─► 403 Forbidden → Method not whitelisted (@frappe.whitelist)
│ ├─► 417 Expectation Failed → Server-side frappe.throw()
│ └─► 401 Unauthorized → Session expired or CSRF token invalid
│
├─► Uncaught (in promise) → Missing try/catch on async frappe.call
│
├─► Field appears blank after set_value → Timing issue (setup vs refresh)
│
├─► cur_frm is undefined → Using cur_frm in list/report context
│
└─► frappe.throw() does not prevent save → Used outside validate event
Error Message → Cause → Fix Table
| Error Message | Cause | Fix |
|---|---|---|
TypeError: Cannot read properties of undefined (reading 'fieldname') |
Field does not exist on DocType or doc not loaded | ALWAYS check frm.doc exists before accessing fields |
TypeError: frm.set_value is not a function |
Using cur_frm shortcut that is undefined |
ALWAYS use the frm parameter from event handler |
Uncaught (in promise) |
Unhandled async rejection from frappe.call | ALWAYS wrap async calls in try/catch |
CSRFTokenError / 403 with CSRF |
Token mismatch after session timeout | ALWAYS use frappe.call() (handles CSRF automatically) |
Not permitted / 403 on frappe.call |
Server method missing @frappe.whitelist() |
ALWAYS add @frappe.whitelist() decorator to API methods |
frappe.throw() not preventing save |
frappe.throw() used outside validate event |
ALWAYS use frappe.throw() only in validate |
field not found: xyz in set_query |
Fieldname typo or field not in child table | Verify exact fieldname against DocType definition |
row.item_code is undefined |
Accessing child row wrong — locals not synced |
Use frappe.get_doc(cdt, cdn) in child table events |
frm.set_value not working |
Called in setup before form fully loaded |
Move field-setting logic to refresh event |
Maximum call stack exceeded |
Circular trigger — field change fires own handler | Use frm.flags guard to break recursion |
Critical Error Patterns
1. cur_frm vs frm: The #1 Beginner Mistake
// ❌ WRONG — cur_frm is undefined in many contexts
frappe.ui.form.on('Sales Order', {
customer(frm) {
cur_frm.set_value('territory', 'Default'); // BREAKS in list view
}
});
// ✅ CORRECT — ALWAYS use the frm parameter
frappe.ui.form.on('Sales Order', {
customer(frm) {
frm.set_value('territory', 'Default');
}
});
Rule: NEVER use cur_frm. ALWAYS use the frm parameter passed to every event handler.
2. Async/Await: Silent Failure Without try/catch
// ❌ WRONG — Unhandled rejection crashes silently
frappe.ui.form.on('Sales Order', {
async customer(frm) {
let r = await frappe.call({
method: 'myapp.api.get_data',
args: { customer: frm.doc.customer }
});
frm.set_value('credit_limit', r.message.limit); // r.message may be null
}
});
// ✅ CORRECT — try/catch with null check
frappe.ui.form.on('Sales Order', {
async customer(frm) {
if (!frm.doc.customer) return;
try {
let r = await frappe.call({
method: 'myapp.api.get_data',
args: { customer: frm.doc.customer }
});
if (r.message) {
frm.set_value('credit_limit', r.message.limit || 0);
}
} catch (error) {
console.error('Customer fetch failed:', error);
frappe.show_alert({
message: __('Could not load customer details'),
indicator: 'red'
}, 5);
}
}
});
3. Child Table Access: Wrong Pattern
// ❌ WRONG — frm.doc.items[0] may not reflect latest state
frappe.ui.form.on('Sales Order Item', {
item_code(frm, cdt, cdn) {
let row = frm.doc.items.find(r => r.name === cdn); // fragile
row.rate = 100; // Does not trigger UI refresh
}
});
// ✅ CORRECT — Use frappe.get_doc and frappe.model.set_value
frappe.ui.form.on('Sales Order Item', {
item_code(frm, cdt, cdn) {
let row = frappe.get_doc(cdt, cdn);
if (!row.item_code) return;
frappe.model.set_value(cdt, cdn, 'rate', 100); // Triggers refresh
}
});
4. Timing: setup vs refresh
// ❌ WRONG — set_value in setup, form not ready
frappe.ui.form.on('Sales Order', {
setup(frm) {
frm.set_value('company', 'My Company'); // May not work
}
});
// ✅ CORRECT — set_query in setup, set_value in refresh/onload
frappe.ui.form.on('Sales Order', {
setup(frm) {
// Filters belong in setup
frm.set_query('customer', () => ({ filters: { disabled: 0 } }));
},
refresh(frm) {
// Value changes belong in refresh (or onload for new docs)
if (frm.is_new()) {
frm.set_value('company', 'My Company');
}
}
});
5. frappe.throw() Scope: Only Works in validate
// ❌ WRONG — throw in customer change does NOT prevent save
frappe.ui.form.on('Sales Order', {
customer(frm) {
if (!frm.doc.customer) {
frappe.throw(__('Customer required')); // Stops script, NOT save
}
}
});
// ✅ CORRECT — throw in validate prevents save
frappe.ui.form.on('Sales Order', {
customer(frm) {
if (!frm.doc.customer) {
frappe.msgprint({ message: __('Customer required'), indicator: 'orange' });
}
},
validate(frm) {
if (!frm.doc.customer) {
frappe.throw(__('Customer is required')); // Prevents save
}
}
});
6. Recursion Guard with Flags
// ❌ WRONG — discount change triggers amount recalc, which triggers discount...
frappe.ui.form.on('Sales Order', {
discount_percent(frm) {
frm.set_value('grand_total', calculate(frm)); // Fires on_change loop
}
});
// ✅ CORRECT — Use flags to break the cycle
frappe.ui.form.on('Sales Order', {
discount_percent(frm) {
if (frm.flags.skip_recalc) return;
frm.flags.skip_recalc = true;
frm.set_value('grand_total', calculate(frm));
frm.flags.skip_recalc = false;
}
});
Debug Tools
| Tool | How to Use | When |
|---|---|---|
| Browser Console (F12) | console.log(frm.doc) |
Inspect form state |
console.table() |
console.table(frm.doc.items) |
View child table rows |
JSON.parse(JSON.stringify(frm.doc)) |
Deep-clone for snapshot | Avoid circular refs in console |
frappe.boot.developer_mode |
Check if dev mode on | Conditional debug logging |
frappe.ui.toolbar.clear_cache() |
Clear client cache | After deploying script changes |
| Network tab (F12) | Filter XHR requests | Inspect frappe.call payloads |
frappe.show_alert({message: 'debug', indicator: 'blue'}, 5) |
Visual debug in UI | Quick feedback without console |
ALWAYS / NEVER Rules
ALWAYS
- Use the
frmparameter — NEVER usecur_frm[v14+] - Wrap async frappe.call in try/catch — Unhandled rejections fail silently
- Use
__()for all user-facing strings — Required for translation - Collect multiple validation errors before calling
frappe.throw() - Use
frappe.get_doc(cdt, cdn)to access child table rows in events - Put
frappe.throw()only invalidateto prevent save - Check
r.messagefor null before accessing server response properties - Use
frappe.model.set_value(cdt, cdn, field, value)in child table events
NEVER
- NEVER use
alert(),confirm(), orprompt()— Use frappe.msgprint / frappe.confirm - NEVER expose stack traces to users — Log to console, show friendly message
- NEVER use
cur_frm— It is unreliable and undefined in many contexts - NEVER leave
console.login production — Use conditionalfrappe.boot.developer_modecheck - NEVER mix
.then()andawaitin the same function — Pick one pattern - NEVER call
frm.set_valueinsetup— Form is not ready; userefreshoronload - NEVER ignore the
errorcallback onfrappe.callwhen using callback style
Reference Files
| File | Contents |
|---|---|
references/examples.md |
Real error scenarios with diagnosis |
references/anti-patterns.md |
Common mistakes with before/after fixes |
references/patterns.md |
Defensive error handling patterns |
Version history
-
v3.1.1
GitHub ↗
Original release notes
## What's new Expanded Keywords in all skill descriptions with user-friendly, non-technical discovery terms. Skills are now easier to find when users describe problems in plain language instead of technical terminology. Examples of added terms: - Symptom-based: "app is slow", "nothing shows", "container won't start" - Beginner-friendly: "how do I start", "what is", "getting started" - Error messages: literal error text users would paste - Alternative names: common synonyms and abbreviations No skill content was changed. Only the Keywords line in SKILL.md frontmatter was expanded.
-
v3.1.0
GitHub ↗
Original release notes
## What's new - package.json with agents.skills[] manifest for external discovery (60 skills) - agents/openai.yaml for OpenAI Codex - GitHub topic agentskills added - SKILLS_LOG.md added to .gitignore - Em-dashes replaced with colons in 31 SKILL.md section headings Enables discovery via npx skills add, skills.sh, LobeHub, and other platforms.
-
v3.0.0
GitHub ↗
Original release notes
## Summary - **60 deterministic skills** for Frappe Framework v14-v16 (up from 53 in v2.0) - **~95% surface area coverage** (up from ~85%) - 7 new skills + 12 existing skills extended with new reference files ## New Skills (7) | Skill | Category | Coverage | |-------|----------|----------| | `frappe-core-translation` | core | i18n, _(), __(), CSV/PO files, string extraction | | `frappe-core-utils` | core | 140+ date, number, string, validation functions | | `frappe-syntax-print` | syntax | Print formats, PDF generation, Letter Head | | `frappe-syntax-query-builder` | syntax | frappe.qb, joins, aggregation, cross-DB | | `frappe-impl-workspace` | impl | Workspace builder, number cards, charts | | `frappe-core-logging` | core | frappe.logger(), Error Log, Sentry integration | | `frappe-core-search` | core | Link search, global search, SQLiteSearch FTS5 | ## Extended Skills (12) 13 new reference files added to existing skills covering: Controls API, Tree View, Portal Generators, Print Format decision tree, Email system, Module/Workspace shipping, complete Document API, custom bench commands, request lifecycle, advanced debugging (VS Code DAP), Frappe Packages, data masking (v16+), and Python type stubs. ## Stats | Category | Count | |----------|:-----:| | syntax/ | 13 | | core/ | 11 | | impl/ | 14 | | errors/ | 7 | | ops/ | 8 | | agents/ | 5 | | testing/ | 2 | | **Total** | **60** | ## Install ```bash git clone https://github.com/OpenAEC-Foundation/Frappe_Claude_Skill_Package.git cp -r Frappe_Claude_Skill_Package/skills/source/* ~/.claude/skills/ ```
-
v2.0.0
GitHub ↗
Original release notes
## Frappe Claude Skill Package v2.0.0 Massive upgrade from 28 ERPNext-specific skills to **53 Frappe Framework skills** covering ~85% of the Frappe surface area. ### What's New - **25 new skills** across 3 new categories (ops, testing, agents) - **28 existing skills** fully rewritten with fresh research - **Renamed** from `erpnext-*` to `frappe-*` (all skills are Frappe Framework, not ERPNext-specific) - **7 categories**: syntax (11), core (7), impl (13), errors (7), ops (8), agents (5), testing (2) ### New Categories - **ops/** — Bench CLI, deployment, backup, performance, upgrades, frontend build, cloud - **testing/** — Unit/integration tests, CI/CD with GitHub Actions - **3 new agents** — debugger, migrator, architect ### Key Improvements - All skills verified against official Frappe docs (March 2026) - v16 features documented: `extend_doctype_class`, data masking, type annotations - MIT license (was LGPL-3.0) - Deterministic language throughout (ALWAYS/NEVER) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
-
v1.1.0
GitHub ↗
Original release notes
V16 compatibility update and documentation improvements. ## Added - USAGE.md with platform-specific guides (Claude.ai, Claude Code, API) - Complete README overhaul with quick start guide ## Changed - All 28 skills updated for ERPNext/Frappe V16 compatibility - Agent Skills now follow standard skill structure - Improved validation: 28/28 skills pass all checks ## Fixed - V16-specific syntax changes in 9 skills - Agent SKILL.md files now under 500 lines
Only the five most recent versions are shown. View full version history at the source ↗
Current listing version
2.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供系统化的 Frappe 客户端脚本错误诊断流程图和常见错误模式
- 涵盖 TypeError、frappe.call 失败、async/await 错误、cur_frm 混淆等高频问题
- 支持 Frappe v14/v15/v16 多版本,适用性广
Highlights
- 触发词覆盖全面,包括 client script error、TypeError、frappe.call、async await 等核心关键词
- 边界清晰,能有效区分客户端脚本错误与其他类型问题
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
未明确说明何时使用此 Skill,建议添加使用场景说明
Recommendation: 在文档开头添加 'When to Use' 章节,说明适用场景
-
文档较长 Reported severity: Minor
主文档内容较多,建议适当拆分或添加目录导航
Recommendation: 考虑将部分内容移至参考文件,或在文档开头添加目录
Highlights
- 结构清晰,包含错误诊断流程图、错误消息对照表、关键错误模式和调试工具
- 提供了详细的代码示例和 ALWAYS/NEVER 规则
Highlights
- 工具来源明确为 Frappe 官方 API,参数使用正确
- 覆盖了主要的异常处理场景,如 try/catch、null 检查、权限验证等
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.