Skip to content

Commit eabae21

Browse files
authored
Require invalid_type_pack for schema-level upgrade_from violations (#60)
1 parent b2ace4c commit eabae21

6 files changed

Lines changed: 92 additions & 1 deletion

File tree

‎05a-data-contracts.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ part of the reviewed manifest and its digest. Ordinary seeds are unaffected.
383383
Engines that do not support this member MUST reject the manifest.
384384

385385
The manifest is invalid (`invalid_type_pack`) when `upgrade_from` appears on a
386-
resource that is not a seed type, when a baseline's digest is not the SHA-256 of
386+
resource that is not a seed type, when it is an empty list, when a baseline lacks
387+
`digest` or `document`, when a baseline's digest is not the SHA-256 of
387388
its document, when two baselines share a digest, when a baseline's digest equals
388389
the resource's own digest, when a baseline document's frontmatter `kind` or
389390
`name` differs from the desired document's, or when a baseline's `version`
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
kind: mdbase.type
3+
name: note
4+
version: 3
5+
description: A note with a creation date and tags.
6+
match:
7+
where:
8+
type: note
9+
schema:
10+
dialect: json-schema-2020-12
11+
value:
12+
type: object
13+
required: [title]
14+
properties:
15+
title: { type: string }
16+
created: { type: string, format: date-time }
17+
tags: { type: array, items: { type: string } }
18+
additionalProperties: true
19+
---
20+
# Note
21+
22+
A note in this collection.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
kind: mdbase.type-pack
2+
id: example.seed-notes
3+
version: 3.0.0
4+
name: Seed note example
5+
resources:
6+
- kind: type
7+
mode: seed
8+
source: _types/note.md
9+
target: _types/note.md
10+
digest: sha256:57160cce297903e123f876d789d518ed83b1cf790edafae660f43f3d44744065
11+
upgrade_from: []
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
kind: mdbase.type
3+
name: note
4+
version: 3
5+
description: A note with a creation date and tags.
6+
match:
7+
where:
8+
type: note
9+
schema:
10+
dialect: json-schema-2020-12
11+
value:
12+
type: object
13+
required: [title]
14+
properties:
15+
title: { type: string }
16+
created: { type: string, format: date-time }
17+
tags: { type: array, items: { type: string } }
18+
additionalProperties: true
19+
---
20+
# Note
21+
22+
A note in this collection.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: mdbase.type-pack
2+
id: example.seed-notes
3+
version: 3.0.0
4+
name: Seed note example
5+
resources:
6+
- kind: type
7+
mode: seed
8+
source: _types/note.md
9+
target: _types/note.md
10+
digest: sha256:57160cce297903e123f876d789d518ed83b1cf790edafae660f43f3d44744065
11+
upgrade_from:
12+
- digest: sha256:28887fbf68c97de99bc271209466bbf457a3635b3ed2ee93e6c5bf8213f53c10
13+
version: 2

‎tests/v0.3/type-packs/type-packs.yaml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,25 @@ groups:
433433
code: invalid_type_pack
434434
covers:
435435
- type_packs.seed_type_upgrade_validation
436+
- id: seed-upgrade-invalid-empty-baselines
437+
name: "invalid upgrade_from (empty-baselines) rejects the manifest with invalid_type_pack"
438+
operation: assess_type_pack
439+
input:
440+
pack: "examples/v0.3/seed-upgrades/invalid-empty-baselines/mdbase-pack.yaml"
441+
expect:
442+
valid: false
443+
error:
444+
code: invalid_type_pack
445+
covers:
446+
- type_packs.seed_type_upgrade_validation
447+
- id: seed-upgrade-invalid-incomplete-baseline
448+
name: "invalid upgrade_from (incomplete-baseline) rejects the manifest with invalid_type_pack"
449+
operation: assess_type_pack
450+
input:
451+
pack: "examples/v0.3/seed-upgrades/invalid-incomplete-baseline/mdbase-pack.yaml"
452+
expect:
453+
valid: false
454+
error:
455+
code: invalid_type_pack
456+
covers:
457+
- type_packs.seed_type_upgrade_validation

0 commit comments

Comments
 (0)