malloy-debug
Skill116 starsChanged 2 months agoMITView on GitHub
Fix Malloy compile errors and understand error messages. Use when encountering errors in .malloy files, user says "fix this error", "malloy error", "compile error", "syntax error", or sees 20+ cascading errors.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- fix-scan-findingSkill
- publisher-releaseSkill
- eval-answerSkill
- eval-diagnoseSkill
- eval-importSkill
- eval-improveSkill
- eval-judgeSkill
- eval-loopSkill
- eval-reportSkill
- malloy-analysis-pitfallsSkill
- malloy-analysis-reportSkill
- malloy-analysisSkill
- malloy-analyzeSkill
- malloy-chartsSkill
- malloy-dashboardsSkill
- malloy-data-app-designSkill
- malloy-defineSkill
- malloy-discoverSkill
- malloy-documentSkill
- malloy-getting-startedSkill
- malloy-gotchas-modelingSkill
- malloy-gotchas-queriesSkill
- malloy-gotchas-renderingSkill
- malloy-html-data-app-embeddingSkill
- malloy-html-data-app-runtimeSkill
- malloy-html-data-appsSkill
- malloy-lookml-reviewSkill
- malloy-materializationSkill
- malloy-materialization-tuningSkill
- malloy-model-as-you-goSkill
- malloy-modelingSkill
- malloy-modelSkill
- malloy-notebook-chatSkill
- malloy-notebooksSkill
- malloy-patternsSkill
- malloy-phrase-detectionSkill
- malloy-powerbi-reviewSkill
- malloy-publishSkill
- malloy-queriesSkill
- malloy-reviewSkill
- malloy-scopeSkill
- malloySkill
- malloy-source-unreachableSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Otherwise, compile by running: Run any query against the source with your query tool and read the error it returns.
- Distinctive: line 21
Only ask the user to open the file in an editor when you know they have the model open in one.
- Distinctive: line 27
Look at FIRST error, ignore all others
- Very specific: line 28
Call search_malloy_docs with the error message if unsure
- Very specific: line 58
Note on
number: Only the bare word needs backticking.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!--
Copyright (c) Credible Data Inc.
SPDX-License-Identifier: MIT
-->Debugging Malloy Errors
Tool names are written bare here -
get_context,execute_query,search_malloy_docs. The exact prefixed name depends on the host surface; match each against the tools you actually have.
Get Diagnostics
Hosts expose errors differently, so take the best path you actually have:
- An editor-diagnostics tool, if your host offers one - call it on the file and read the errors straight out.
- Otherwise, compile by running. Run any query against the source with your query tool and read the error it returns. Every host that can run Malloy can do this, including chat surfaces with no editor.
Only ask the user to open the file in an editor when you know they have the model open in one. On a hosted chat surface there is no local checkout to open, and the query path above is the one that works.
Strategy
Errors cascade. Later errors may be caused by or hidden behind earlier ones. Fix the FIRST error only, re-check diagnostics, repeat. Do not attempt to fix multiple errors at once.
- Look at FIRST error, ignore all others
- Call
search_malloy_docswith the error message if unsure - Fix that one issue, re-check diagnostics
- Repeat until clean. New errors may appear as earlier ones are resolved
Quick Fixes
| Error | Fix |
| "Unknown field" | Check typo, source order, wrong source, or missing import |
| "Can't use type string" | Cast: field::number |
| "Aggregate not allowed in where" | Use having: instead |
| 20+ random errors | Backtick reserved word (`Date`, `Hour`, `number`) |
Can't find field 'X' to set access modifier | An include {} sits before the extend { rename: }. Rename first, then include {} naming the field by its new name (see skill:malloy-gotchas-modeling § Field Management) |
IO Error: No files found that match the pattern "data/x.csv" | Data-file path, not the model. Relative duckdb.table() paths resolve against the DuckDB workingDirectory; Publisher sets it to the package root, but a relative workingDirectory in malloy-config.json resolves against the process cwd. Make it absolute (see skill:malloy-gotchas-modeling § Relative Data-File Paths). The "not defined" errors under it are cascade, not real |
| Import path errors | Check paths: import "orders.malloy". All files should be in the same directory (flat layout) |
unexpected 'from' | from() was removed from the language. Use the query directly: source: x is q extend {...}, or source: x is (q -> {...}) extend {...} |
| Query-based source errors | Verify the source query returns the expected columns, check that imported sources are defined |
| "Cannot redefine 'X'" | Field already exists from query-based source (-> { group_by, aggregate }). Remove the dimension, add only NEW derived fields in extend {}. Use include {} to add #(doc) tags to existing fields. |
Gotchas Checklist
Backtick Reserved Words
// WRONG // RIGHT
dimension: d is Date::date dimension: d is `Date`::dateCommon reserved words: Date, Timestamp, Type, Hour, source, year, month, day, week, quarter, count, sum, avg, min, max, number, string, boolean, true, false, order, select, from, where, index, table, time, now, today, range, window, row, current
When in doubt, backtick it. See the Malloy docs (https://docs.malloydata.dev) for the full categorized list of reserved words.
Note on number: Only the bare word needs backticking. Compound names like account_number are fine.
Use is not null for NULL Checks
// WRONG // RIGHT
is_sold is sold_at != null is_sold is sold_at is not nullCall Date Functions, Don't Access as Properties
// WRONG // RIGHT
dow is created_at.day_of_week dow is day_of_week(created_at)Properties: .month, .year, .day | Functions: day_of_week(), week(), hour()
Use having: for Aggregate Filters
// WRONG // RIGHT
where: order_count > 10 having: order_count > 10Cast Strings Before Aggregating
// WRONG // RIGHT
avg(score) avg(score::number)Use Boolean Literals Without Quotes
// WRONG // RIGHT
where: active = 'true' where: active = trueAlias Joined Fields Before Using in order_by
// WRONG // RIGHT
group_by: races.year group_by: yr is races.year
order_by: races.year order_by: yrUse Method Syntax for Joined Aggregates
// WRONG // RIGHT
sum(items.cost) items.cost.sum()Define Lookup Tables First (or Use Imports)
// Single file: define lookup tables before referencing them
// Multi-file: use import statements
import "customers.malloy"
source: orders is conn.table('orders') extend {
join_one: customers with customer_id // Works because customers imported
}Use nullif for Division
// WRONG // RIGHT
a / b a / nullif(b, 0)Cross-File Errors
| Error | Fix |
| "Can't find source X" | Add import "X.malloy" at top of file (all files in same directory) |
| Wrong import path | All .malloy files should be in the package root (flat layout). Use import "orders.malloy", not import "../sources/orders.malloy" |
| Circular imports | Source A imports Source B which imports Source A. Restructure to break the cycle |
| Query-based source "Can't find field" | Verify the source query's GROUP BY and aggregate fields match what you reference in extend {} |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

