You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
left $OCFErrHashMismatch murl (renderByteArray expectedMetaHashBs) (renderByteArray metadataHash)
132
133
_ ->pure (metadataHash, Nothing)
133
-
-- Hash matches, now decode as generic JSON (this should still fail if not valid JSON)
134
-
decodedValue <-
134
+
-- Hash matches, now try to decode as generic JSON
135
+
-- If this fails, we still want to store the data with is_valid = NULL and an error message
136
+
(decodedValue, isValidJson) <-
135
137
caseAeson.eitherDecode' @Aeson.Value lbs of
136
-
Left err -> left $OCFErrJsonDecodeFail murl (Text.pack err)
137
-
Right res ->pure res
138
-
-- Try to decode into strongly-typed vote data structure
138
+
Left err ->
139
+
-- Not valid JSON - create an error message object
140
+
pure (Aeson.object [("error", Aeson.String"Content is not valid JSON. See bytes column for raw data."), ("parse_error", Aeson.String$Text.pack err)], False)
141
+
Right res ->pure (res, True)
142
+
-- Try to decode into strongly-typed vote data structure (only if JSON was valid)
139
143
-- If this fails (e.g., doNotList is string instead of bool), we still store with is_valid = false
140
-
let ocvd =caseVote.eitherDecodeOffChainVoteData lbs anchorType of
141
-
Left _err ->Nothing-- Don't fail, just return Nothing (will set is_valid = false)
142
-
Right res ->Just res
143
-
pure (ocvd, decodedValue, hsh, mWarning)
144
+
let ocvd =
145
+
if isValidJson
146
+
thencaseVote.eitherDecodeOffChainVoteData lbs anchorType of
147
+
Left _err ->Nothing-- Don't fail, just return Nothing (will set is_valid = false)
148
+
Right res ->Just res
149
+
elseNothing-- Not valid JSON, so can't parse as CIP
150
+
pure (ocvd, decodedValue, hsh, mWarning, isValidJson)
Copy file name to clipboardExpand all lines: doc/schema.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1014,7 +1014,14 @@ A table containing pool offchain data fetch errors.
1014
1014
1015
1015
### `off_chain_vote_data`
1016
1016
1017
-
The table with the offchain metadata related to Vote Anchors. It accepts metadata in a more lenient way than what's decribed in CIP-100. New in 13.2-Conway.
1017
+
Stores off-chain voting anchor data with validation status. The table accepts metadata in a more lenient way than what's described in CIP-100. Only data with hash matches are stored here; hash mismatches are stored in off_chain_vote_fetch_error for retry.
1018
+
1019
+
The is_valid column indicates the parsing status:
1020
+
• TRUE: Content is valid JSON AND conforms to CIP-100 schema. All related fields (language, comment) and related tables (off_chain_vote_gov_action_data, off_chain_vote_drep_data, off_chain_vote_author, off_chain_vote_reference, off_chain_vote_external_update) are populated.
1021
+
• FALSE: Hash matches and content is valid JSON BUT does not conform to CIP-100 schema. The json column contains the actual JSON, but language/comment fields and related tables remain empty.
1022
+
• NULL: Hash matches but content is not valid JSON at all. The json column contains an error message, bytes column has raw data. Language/comment fields and related tables remain empty.
1023
+
1024
+
New in 13.2-Conway.
1018
1025
1019
1026
* Primary Id: `id`
1020
1027
@@ -1028,7 +1035,7 @@ The table with the offchain metadata related to Vote Anchors. It accepts metadat
1028
1035
|`json`| jsonb | The payload as JSON. |
1029
1036
|`bytes`| bytea | The raw bytes of the payload. |
1030
1037
|`warning`| string | A warning that occured while validating the metadata. |
1031
-
|`is_valid`| boolean |False if the data is found invalid. db-sync leaves this field null since it normally populates off_chain_vote_fetch_error for invalid data. It can be used manually to mark some metadata invalid by clients. |
1038
+
|`is_valid`| boolean |Indicates validation status: TRUE for valid JSON conforming to CIP-100 schema, FALSE for valid JSON not conforming to CIP-100 schema, NULL for content that is not valid JSON at all. |
0 commit comments