Skip to content

Structured issue locations: field, source key and line #191

Open

Description

@mindsocket

Problem

FileValidationResult reports issues keyed by strings such as schema:/status:enum:active, with a message. A host that wants to put an issue on its line (the Obsidian plugin does) has to:

  • parse the property name out of the key (schema:/<property>…),
  • find that property's line by hand-parsing the frontmatter YAML (the plugin matches ^key: lines in the first 200 lines),
  • map the schema's field name back to the note's own key through the markdown plugin's fieldMap.

All three repeat knowledge core already has. They break on cases core handles: nested properties, quoted or flow-style keys, and a space whose parse plugin isn't markdown.

Proposal

Give each issue a structured location alongside its key and message, for example:

location?: {
  /** The field as the schema names it, as a JSON pointer into the node (e.g. "/status", "/links/0"). */
  field?: string;
  /** The key as written in the file, after reversing fieldMap (e.g. "record_type"). */
  sourceKey?: string;
  /** Where that key sits in the file, when the parse plugin knows (1-based line). */
  line?: number;
}

Schema issues would carry field and, from the markdown plugin, sourceKey and line. Rule, link and hierarchy issues would carry what applies, or nothing.

Notes

  • Keys stay as they are for compatibility. Hosts move to location when it's present.
  • Source positions need the markdown plugin to keep key positions when it parses frontmatter. gray-matter doesn't give positions, so this may need a YAML parser that does, or a lightweight line scan inside the plugin, which at least centralises the hand-parse.
  • With this, the Obsidian plugin drops parseFrontmatter, extractProperty and its fieldMap inversion (src/editor-extension.ts).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions