MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseSettingsFileUncached

Function parseSettingsFileUncached

src/utils/settings/settings.ts:206–236  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

204}
205
206function parseSettingsFileUncached(path: string): {
207 settings: SettingsJson | null
208 errors: ValidationError[]
209} {
210 try {
211 const { resolvedPath } = safeResolvePath(getFsImplementation(), path)
212 const content = readFileSync(resolvedPath)
213
214 if (content.trim() === '') {
215 return { settings: {}, errors: [] }
216 }
217
218 const data = safeParseJSON(content, false)
219
220 // Filter invalid permission rules before schema validation so one bad
221 // rule doesn't cause the entire settings file to be rejected.
222 const ruleWarnings = filterInvalidPermissionRules(data, path)
223
224 const result = SettingsSchema().safeParse(data)
225
226 if (!result.success) {
227 const errors = formatZodError(result.error, path)
228 return { settings: null, errors: [...ruleWarnings, ...errors] }
229 }
230
231 return { settings: result.data, errors: ruleWarnings }
232 } catch (error) {
233 handleFileSystemError(error, path)
234 return { settings: null, errors: [] }
235 }
236}
237
238/**
239 * Get the absolute path to the associated file root for a given settings source

Callers 1

parseSettingsFileFunction · 0.85

Calls 6

safeResolvePathFunction · 0.85
getFsImplementationFunction · 0.85
formatZodErrorFunction · 0.85
handleFileSystemErrorFunction · 0.85
readFileSyncFunction · 0.50

Tested by

no test coverage detected