Skip to content

Commit 56b78e5

Browse files
committed
fix: expose fetch error in /governance/dreps/:drep_id/metadata
1 parent 694313c commit 56b78e5

9 files changed

Lines changed: 154 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ Unreleased changes are in the `master` branch.
1111

1212
### Fixed
1313

14-
- added PlutusV3 to the type field of the script object, to match the actual API response types
14+
- Added PlutusV3 to the type field of the script object, to match the actual API response types
15+
16+
- Exposed dbsync off-chain metadata fetch errors in metadata responses in `/governance/dreps/:drep_id/metadata`
17+
- Error object structure:
18+
```ts
19+
{
20+
"code": "HASH_MISMATCH" | "CONNECTION_ERROR" | "HTTP_RESPONSE_ERROR" | "DECODE_ERROR" | "SIZE_EXCEEDED" | "UNKNOWN_ERROR",
21+
"message": "Human-readable description of the error"
22+
}
23+
```
24+
- If metadata are available, the `error` field is omitted
1525

1626
## [0.1.82] - 2025-10-20
1727

blockfrost-openapi.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6840,6 +6840,26 @@ components:
68406840
bytes:
68416841
type: string
68426842
description: Content of the metadata (raw)
6843+
error:
6844+
type: object
6845+
description: Present when metadata could not be fetched or validated.
6846+
properties:
6847+
code:
6848+
type: string
6849+
description: Stable machine-readable error code.
6850+
enum:
6851+
- HASH_MISMATCH
6852+
- CONNECTION_ERROR
6853+
- HTTP_RESPONSE_ERROR
6854+
- DECODE_ERROR
6855+
- SIZE_EXCEEDED
6856+
- UNKNOWN_ERROR
6857+
message:
6858+
type: string
6859+
description: Human-readable description of the error.
6860+
required:
6861+
- code
6862+
- message
68436863
required:
68446864
- drep_id
68456865
- hex

docs/blockfrost-openapi.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7174,6 +7174,26 @@ components:
71747174
bytes:
71757175
type: string
71767176
description: Content of the metadata (raw)
7177+
error:
7178+
type: object
7179+
description: Present when metadata could not be fetched or validated.
7180+
properties:
7181+
code:
7182+
type: string
7183+
description: Stable machine-readable error code.
7184+
enum:
7185+
- HASH_MISMATCH
7186+
- CONNECTION_ERROR
7187+
- HTTP_RESPONSE_ERROR
7188+
- DECODE_ERROR
7189+
- SIZE_EXCEEDED
7190+
- UNKNOWN_ERROR
7191+
message:
7192+
type: string
7193+
description: Human-readable description of the error.
7194+
required:
7195+
- code
7196+
- message
71777197
required:
71787198
- drep_id
71797199
- hex

json-schema.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

openapi.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9426,6 +9426,32 @@
94269426
"bytes": {
94279427
"type": "string",
94289428
"description": "Content of the metadata (raw)"
9429+
},
9430+
"error": {
9431+
"type": "object",
9432+
"description": "Present when metadata could not be fetched or validated.",
9433+
"properties": {
9434+
"code": {
9435+
"type": "string",
9436+
"description": "Stable machine-readable error code.",
9437+
"enum": [
9438+
"HASH_MISMATCH",
9439+
"CONNECTION_ERROR",
9440+
"HTTP_RESPONSE_ERROR",
9441+
"DECODE_ERROR",
9442+
"SIZE_EXCEEDED",
9443+
"UNKNOWN_ERROR"
9444+
]
9445+
},
9446+
"message": {
9447+
"type": "string",
9448+
"description": "Human-readable description of the error."
9449+
}
9450+
},
9451+
"required": [
9452+
"code",
9453+
"message"
9454+
]
94299455
}
94309456
},
94319457
"required": [

openapi.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7174,6 +7174,26 @@ components:
71747174
bytes:
71757175
type: string
71767176
description: Content of the metadata (raw)
7177+
error:
7178+
type: object
7179+
description: Present when metadata could not be fetched or validated.
7180+
properties:
7181+
code:
7182+
type: string
7183+
description: Stable machine-readable error code.
7184+
enum:
7185+
- HASH_MISMATCH
7186+
- CONNECTION_ERROR
7187+
- HTTP_RESPONSE_ERROR
7188+
- DECODE_ERROR
7189+
- SIZE_EXCEEDED
7190+
- UNKNOWN_ERROR
7191+
message:
7192+
type: string
7193+
description: Human-readable description of the error.
7194+
required:
7195+
- code
7196+
- message
71777197
required:
71787198
- drep_id
71797199
- hex

src/generated-types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7343,6 +7343,16 @@ export interface components {
73437343
} | unknown[] | number | boolean | null;
73447344
/** @description Content of the metadata (raw) */
73457345
bytes: string;
7346+
/** @description Present when metadata could not be fetched or validated. */
7347+
error?: {
7348+
/**
7349+
* @description Stable machine-readable error code.
7350+
* @enum {string}
7351+
*/
7352+
code: "HASH_MISMATCH" | "CONNECTION_ERROR" | "HTTP_RESPONSE_ERROR" | "DECODE_ERROR" | "SIZE_EXCEEDED" | "UNKNOWN_ERROR";
7353+
/** @description Human-readable description of the error. */
7354+
message: string;
7355+
};
73467356
};
73477357
/** @example [
73487358
* {

src/schemas/governance/drep_metadata.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ properties:
2929
bytes:
3030
type: string
3131
description: Content of the metadata (raw)
32+
error:
33+
type: object
34+
description: Present when metadata could not be fetched or validated.
35+
properties:
36+
code:
37+
type: string
38+
description: Stable machine-readable error code.
39+
enum:
40+
- HASH_MISMATCH
41+
- CONNECTION_ERROR
42+
- HTTP_RESPONSE_ERROR
43+
- DECODE_ERROR
44+
- SIZE_EXCEEDED
45+
- UNKNOWN_ERROR
46+
message:
47+
type: string
48+
description: Human-readable description of the error.
49+
required:
50+
- code
51+
- message
3252
required:
3353
- drep_id
3454
- hex

test/tests/__snapshots__/get-schema-for-endpoint.test.ts.snap

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11998,6 +11998,32 @@ under which it is valid
1199811998
"description": "Bech32 encoded addresses",
1199911999
"type": "string",
1200012000
},
12001+
"error": {
12002+
"description": "Present when metadata could not be fetched or validated.",
12003+
"properties": {
12004+
"code": {
12005+
"description": "Stable machine-readable error code.",
12006+
"enum": [
12007+
"HASH_MISMATCH",
12008+
"CONNECTION_ERROR",
12009+
"HTTP_RESPONSE_ERROR",
12010+
"DECODE_ERROR",
12011+
"SIZE_EXCEEDED",
12012+
"UNKNOWN_ERROR",
12013+
],
12014+
"type": "string",
12015+
},
12016+
"message": {
12017+
"description": "Human-readable description of the error.",
12018+
"type": "string",
12019+
},
12020+
},
12021+
"required": [
12022+
"code",
12023+
"message",
12024+
],
12025+
"type": "object",
12026+
},
1200112027
"hash": {
1200212028
"description": "Hash of the metadata file",
1200312029
"example": "69c0c68cb57f4a5b4a87bad896fc274678e7aea98e200fa14a1cb40c0cab1d8c"",

0 commit comments

Comments
 (0)