Problem
If an .afm.md file contains one or more blank lines before the first ---, the interpreter ignores the entire front matter.
As a result, the model configuration defined in the file is not used, and the interpreter falls back to its default provider. This eventually causes a misleading error message.
How to Reproduce
Use a normal AFM file, but leave a blank line before the front matter:
---
model:
provider: "ollama"
name: "llama3"
---
# Role
...
Then run the interpreter.
Expected Behavior
Leading blank lines should be ignored.
The parser should skip any blank lines before the opening ---, parse the front matter normally, and use the model configuration defined in the file.
For the example above, the interpreter should use:
provider: "ollama"
name: "llama3"
Actual Behavior
The front matter is ignored because it does not start on the first line of the file.
As a result, the model configuration is never loaded, and the interpreter falls back to its default provider.
This later results in an unrelated error such as:
ProviderError: Provider 'openai': No API key found.
The configured provider from the file is never used.
Root Cause
Both parsers only check the first line of the file for the opening ---.
Python
extract_raw_frontmatter() in:
packages/afm-core/src/afm/parser.py
Ballerina
parseAfm() in:
ballerina-interpreter/parser.bal
If the file begins with one or more blank lines, both parsers assume that no front matter exists and skip parsing it entirely.
Suggested Fix
Update both interpreters to ignore leading blank lines before checking for the opening ---.
This allows front matter to be parsed correctly even when the file starts with whitespace, making the behavior more tolerant and user-friendly.
Problem
If an
.afm.mdfile contains one or more blank lines before the first---, the interpreter ignores the entire front matter.As a result, the model configuration defined in the file is not used, and the interpreter falls back to its default provider. This eventually causes a misleading error message.
How to Reproduce
Use a normal AFM file, but leave a blank line before the front matter:
Then run the interpreter.
Expected Behavior
Leading blank lines should be ignored.
The parser should skip any blank lines before the opening
---, parse the front matter normally, and use the model configuration defined in the file.For the example above, the interpreter should use:
Actual Behavior
The front matter is ignored because it does not start on the first line of the file.
As a result, the model configuration is never loaded, and the interpreter falls back to its default provider.
This later results in an unrelated error such as:
The configured provider from the file is never used.
Root Cause
Both parsers only check the first line of the file for the opening
---.Python
extract_raw_frontmatter()in:Ballerina
parseAfm()in:If the file begins with one or more blank lines, both parsers assume that no front matter exists and skip parsing it entirely.
Suggested Fix
Update both interpreters to ignore leading blank lines before checking for the opening
---.This allows front matter to be parsed correctly even when the file starts with whitespace, making the behavior more tolerant and user-friendly.