MCPcopy Index your code
hub / github.com/deepnote/deepnote / parseAndValidate

Function parseAndValidate

packages/blocks/src/deepnote-file/parse-yaml.ts:97–113  ·  view source on GitHub ↗

* Parse and validate YAML document in a single pass. * Checks for duplicate keys and other parsing errors, then converts to JavaScript object.

(yamlContent: string)

Source from the content-addressed store, hash-verified

95 * Checks for duplicate keys and other parsing errors, then converts to JavaScript object.
96 */
97function parseAndValidate(yamlContent: string): unknown {
98 const doc = parseDocument(yamlContent, {
99 strict: true,
100 uniqueKeys: true,
101 version: '1.2',
102 })
103
104 if (doc.errors.length > 0) {
105 const duplicateKeyError = doc.errors.find(err => err.message.includes('duplicate') || err.message.includes('key'))
106 if (duplicateKeyError) {
107 throw new YamlParseError(`Duplicate keys detected in Deepnote file: ${duplicateKeyError.message}`)
108 }
109 throw new YamlParseError(`YAML parsing error: ${doc.errors[0].message}`)
110 }
111
112 return doc.toJS()
113}
114
115/**
116 * Parse YAML content with strict validation rules:

Callers 1

parseYamlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected