Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 7a936c1

Browse files
author
Chris McConnell
authored
Fix #1289 (#1290)
The fix was to make the error reporting better. In this case a proxy error would return a string which we would then treat as an object. Also cleaned up a few lint issues. Co-authored-by: Chris McConnell <chrimc>
1 parent 6321dcc commit 7a936c1

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"999999",
9191
"--colors",
9292
"-g",
93-
"dialog:merge.*missing schema.*"
93+
"dialog:merge.*"
9494
],
9595
"cwd": "${workspaceFolder}/packages/dialog",
9696
"internalConsoleOptions": "openOnSessionStart",

packages/dialog/src/library/schemaMerger.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export class SchemaMerger {
502502
this.log('')
503503
imports = await this.copyAssets()
504504
} catch (e) {
505-
this.mergingError(e)
505+
this.mergingError((e as string | Error))
506506
}
507507
if (this.failed) {
508508
this.error('*** Could not merge components ***')
@@ -629,7 +629,7 @@ export class SchemaMerger {
629629
this.definitions[kind] = component
630630
}
631631
} catch (e) {
632-
this.parsingError(e)
632+
this.parsingError((e as string | Error))
633633
}
634634
}
635635
this.currentFile = ''
@@ -752,7 +752,7 @@ export class SchemaMerger {
752752
delete component.$schema
753753
locale[kindName] = mergeObjects(locale[kindName], component)
754754
} catch (e) {
755-
this.parsingError(e)
755+
this.parsingError((e as string | Error))
756756
}
757757
}
758758

@@ -861,7 +861,7 @@ export class SchemaMerger {
861861
if (msg) {
862862
this.log(msg)
863863
}
864-
this.mergingError(e)
864+
this.mergingError((e as string | Error))
865865
}
866866
}
867867

@@ -1178,7 +1178,7 @@ export class SchemaMerger {
11781178
this.parsingWarning('Missing package')
11791179
}
11801180
} catch (e) {
1181-
this.parsingWarning(e.message)
1181+
this.parsingWarning((e as Error).message)
11821182
} finally {
11831183
this.currentFile = this.currentParent().metadata.path
11841184
}
@@ -1830,7 +1830,11 @@ export class SchemaMerger {
18301830
// New source
18311831
this.currentFile = path
18321832
this.vlog(`Bundling ${path}`)
1833-
schema.definitions[name] = await getJSON(path)
1833+
const definition = await getJSON(path)
1834+
if (typeof (definition) !== 'object') {
1835+
throw new Error(`Error ${val} did not resolve to JSON Schema object ${definition}`)
1836+
}
1837+
schema.definitions[name] = definition
18341838
sources.push(name)
18351839
}
18361840
const ref = `#/definitions/${name}${pointer}`

packages/dialog/test/commands/dialog/merge.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,18 @@ describe('dialog:merge', async () => {
499499
scope.done()
500500
nock.cleanAll()
501501
})
502+
503+
it('non-object ref', async() => {
504+
const scope = nock('http://json-schema.org')
505+
.get(/draft-07/)
506+
.reply(200, '<xml></xml>')
507+
.persist()
508+
const [merged, lines] = await merge(['nuget/nuget3/1.0.0/*.schema'], 'app.schema')
509+
assert(!merged, 'Merging should fail')
510+
assert(countMatches(/did not resolve to JSON Schema/i, lines) === 1, 'Did not detect bad definition')
511+
scope.done()
512+
nock.cleanAll()
513+
})
502514
})
503515

504516
/* TODO: These tests are related to verify and need to be updated and moved there.

packages/orchestrator/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
"typescript": "^4.0.3",
4949
"sinon": "^9.0.2"
5050
},
51-
"engines": {
52-
"node": ">=8.0.0"
53-
},
5451
"files": [
5552
"/lib",
5653
"/npm-shrinkwrap.json",

0 commit comments

Comments
 (0)