···295295### Permission Errors
296296297297Ensure you have write permissions for the project directory to create `.mlf/`.
298298-299299-## Future Features
300300-301301-Planned enhancements:
302302-303303-- `--force` flag to re-fetch cached lexicons
304304-- Version pinning (fetch specific lexicon versions)
305305-- Private/authenticated repositories
306306-- Offline mode with local cache
307307-- Fetch from local directories
-335
website/content/docs/cli/08-errors.md
···11-+++
22-title = "Error Messages"
33-description = "Understanding MLF error diagnostics"
44-weight = 8
55-+++
66-77-MLF provides rich, helpful error messages with source code context and suggestions for fixing issues.
88-99-## Error Format
1010-1111-All MLF errors follow this format:
1212-1313-```
1414- × Error title
1515- ╭─[file.mlf:5:12]
1616- 5 │ author: ProfileView,
1717- · ^^^^^^^^^^^ error message
1818- ╰────
1919- help: Suggestion for fixing the issue
2020-```
2121-2222-**Components:**
2323-- **× Error title** - Brief description of the error
2424-- **Source location** - File name, line, and column
2525-- **Source context** - The relevant code snippet
2626-- **Error span** - Highlighted location with `^^^`
2727-- **help:** - Actionable suggestion for fixing
2828-2929-## Common Errors
3030-3131-### Parse Errors
3232-3333-#### Expected Token
3434-3535-```
3636- × Expected '}', found ','
3737- ╭─[thread.mlf:10:5]
3838-10 │ title: string,
3939- · ^ expected '}'
4040- ╰────
4141- help: Check for missing closing braces or extra commas
4242-```
4343-4444-**Cause:** Syntax error in MLF code
4545-4646-**Fix:** Correct the syntax according to MLF grammar
4747-4848-#### Invalid Identifier
4949-5050-```
5151- × Invalid identifier: '123invalid'
5252- ╭─[thread.mlf:5:5]
5353- 5 │ 123invalid: string,
5454- · ^^^^^^^^^^ identifiers cannot start with numbers
5555- ╰────
5656- help: Identifiers must start with a letter or underscore
5757-```
5858-5959-**Cause:** Identifier doesn't follow naming rules
6060-6161-**Fix:** Start identifiers with letters or underscores
6262-6363-### Type Errors
6464-6565-#### Undefined Reference
6666-6767-```
6868- × Undefined reference to 'ProfileView'
6969- ╭─[thread.mlf:8:12]
7070- 8 │ author: ProfileView,
7171- · ^^^^^^^^^^^ 'ProfileView' is not defined
7272- ╰────
7373- help: Make sure this type is defined in the same file or imported via 'use'.
7474-```
7575-7676-**Causes:**
7777-- Type is not defined
7878-- Type is in another file and not imported
7979-- Typo in type name
8080-8181-**Fixes:**
8282-- Define the type in the same file
8383-- Use `mlf fetch` to download external lexicons
8484-- Add a `use` statement (if MLF supports imports)
8585-- Check spelling
8686-8787-#### Type Mismatch
8888-8989-```
9090- × Type mismatch: expected integer, found string
9191- ╭─[thread.mlf:12:15]
9292-12 │ count: string,
9393- · ^^^^^^ expected integer type
9494- ╰────
9595- help: Change this to 'integer' or update the constraint
9696-```
9797-9898-**Cause:** Field type doesn't match its definition
9999-100100-**Fix:** Update the type to match the schema
101101-102102-### Constraint Errors
103103-104104-#### Invalid Constraint
105105-106106-```
107107- × Invalid constraint for type 'integer': 'maxLength'
108108- ╭─[thread.mlf:15:9]
109109-15 │ maxLength: 100,
110110- · ^^^^^^^^^ 'maxLength' is only valid for string types
111111- ╰────
112112- help: Use 'maximum' for integer constraints
113113-```
114114-115115-**Cause:** Constraint doesn't apply to the type
116116-117117-**Fix:** Use the correct constraint for the type:
118118-- String: `maxLength`, `minLength`, `maxGraphemes`, `minGraphemes`
119119-- Integer: `minimum`, `maximum`
120120-- Array: `maxLength`, `minLength`
121121-122122-#### Constraint Value Error
123123-124124-```
125125- × Constraint value must be positive
126126- ╭─[thread.mlf:18:20]
127127-18 │ maxLength: -10,
128128- · ^^^ negative value not allowed
129129- ╰────
130130- help: Use a positive integer value
131131-```
132132-133133-**Cause:** Constraint value is invalid
134134-135135-**Fix:** Use a valid value according to the constraint rules
136136-137137-### Record Errors
138138-139139-#### Missing Record Key
140140-141141-```
142142- × Record definition must specify a key type
143143- ╭─[thread.mlf:3:1]
144144- 3 │ record main {
145145- · ^^^^^^^^^^^ missing key specification
146146- ╰────
147147- help: Add 'key: "tid"' or another valid key type to the record
148148-```
149149-150150-**Cause:** Record doesn't specify how records are keyed
151151-152152-**Fix:** Add a key specification to the record definition
153153-154154-### XRPC Errors
155155-156156-#### Invalid Response Code
157157-158158-```
159159- × Invalid HTTP response code: 999
160160- ╭─[api.mlf:25:5]
161161-25 │ 999: error,
162162- · ^^^ response code must be between 200-599
163163- ╰────
164164- help: Use a valid HTTP status code
165165-```
166166-167167-**Cause:** Invalid HTTP status code in query/procedure
168168-169169-**Fix:** Use standard HTTP status codes (200, 400, 401, 404, 500, etc.)
170170-171171-#### Missing Required Response
172172-173173-```
174174- × Query/procedure must define at least one success response
175175- ╭─[api.mlf:20:1]
176176-20 │ query getProfile(...) {
177177- · ^^^^^^^^^^^^^^^^^^^^^ no 200-level responses defined
178178- ╰────
179179- help: Add at least one 2xx response (typically 200)
180180-```
181181-182182-**Cause:** XRPC method has no success responses
183183-184184-**Fix:** Add a 200-level response
185185-186186-### Union Errors
187187-188188-#### Empty Union
189189-190190-```
191191- × Union must have at least one type
192192- ╭─[thread.mlf:30:15]
193193-30 │ data: unit | ,
194194- · ^ empty union
195195- ╰────
196196- help: Add at least one type to the union
197197-```
198198-199199-**Cause:** Union has no types
200200-201201-**Fix:** Add types to the union: `string | integer`
202202-203203-#### Duplicate Union Types
204204-205205-```
206206- × Duplicate type in union: 'string'
207207- ╭─[thread.mlf:32:20]
208208-32 │ data: string | string,
209209- · ^^^^^^ duplicate type
210210- ╰────
211211- help: Remove duplicate types from the union
212212-```
213213-214214-**Cause:** Same type appears multiple times in union
215215-216216-**Fix:** Remove duplicates
217217-218218-## Validation Errors
219219-220220-### Record Validation
221221-222222-```
223223-✗ Record validation failed with 2 error(s):
224224- • Field 'title' is required but missing
225225- • Field 'count': expected integer, found "123"
226226-```
227227-228228-**Cause:** JSON record doesn't match lexicon schema
229229-230230-**Fix:** Update the JSON to match the schema
231231-232232-## Generation Errors
233233-234234-### File Read Error
235235-236236-```
237237-Failed to read file: permission denied
238238-```
239239-240240-**Cause:** Cannot read input file
241241-242242-**Fix:** Check file permissions and path
243243-244244-### Type Resolution Error
245245-246246-```
247247-Type resolution error: circular reference detected
248248-```
249249-250250-**Cause:** Types reference each other in a cycle
251251-252252-**Fix:** Break the circular dependency
253253-254254-### Code Generation Error
255255-256256-```
257257-Generator 'typescript' not found
258258-```
259259-260260-**Cause:** Generator feature not enabled
261261-262262-**Fix:** Install with `--features typescript` or use `--all-features`
263263-264264-## Fetch Errors
265265-266266-### DNS Error
267267-268268-```
269269-✗ DNS lookup failed: No TXT record found for _lexicon.place.stream
270270-```
271271-272272-**Cause:** Domain has no lexicon TXT record
273273-274274-**Fix:** Verify the namespace is correct and has published lexicons
275275-276276-### Network Error
277277-278278-```
279279-✗ Failed to fetch lexicon records: connection timeout
280280-```
281281-282282-**Cause:** Network connectivity issues
283283-284284-**Fix:** Check internet connection and try again
285285-286286-### Parse Error
287287-288288-```
289289-✗ Failed to parse lexicon JSON: unexpected end of input
290290-```
291291-292292-**Cause:** Malformed JSON from remote repository
293293-294294-**Fix:** Report issue to namespace maintainer
295295-296296-## Exit Codes
297297-298298-All MLF commands use standard exit codes:
299299-300300-- `0` - Success
301301-- `1` - Error occurred
302302-303303-Use in scripts:
304304-305305-```bash
306306-if mlf check; then
307307- echo "✓ Valid"
308308-else
309309- echo "✗ Invalid"
310310- exit 1
311311-fi
312312-```
313313-314314-## Tips for Reading Errors
315315-316316-1. **Read the title** - Gives you the high-level issue
317317-2. **Check the location** - Find the exact line and column
318318-3. **Examine the span** - See what code is problematic
319319-4. **Follow the help** - Actionable suggestions for fixes
320320-5. **Look for patterns** - Similar errors often have similar fixes
321321-322322-## Reporting Bugs
323323-324324-If you encounter an error that seems like a bug:
325325-326326-1. Note the exact error message
327327-2. Create a minimal reproduction case
328328-3. Check if it's a known issue
329329-4. Report at: https://github.com/anthropics/claude-code/issues
330330-331331-Include:
332332-- MLF version (`mlf --version`)
333333-- Complete error message
334334-- Minimal MLF code that reproduces the issue
335335-- Expected behavior vs actual behavior