Chia-Network / cadt

Climate Action Data Trust
Apache License 2.0
35 stars 13 forks source link

FIX [CADT] - When doing a PUT update on unit record, issuance appears to be required even though it is not when creating a unit #1064

Open ccornick opened 4 months ago

ccornick commented 4 months ago

for copy pasting into an issue on Github:

The issuance field is not required when creating a unit as documented here https://github.com/Chia-Network/cadt/blob/develop/docs/cadt_rpc_api.md#create-a-new-unit-using-only-the-required-fields. If you don't supply a unit, your record will look like the following:


            "warehouseUnitId": "3b2ff4b5-0779-4cec-b794-3c4f79833b5c",
            "issuanceId": null,
            "projectLocationId": null,
            "orgUid": "fc90b2074b51491f19ceaf06b164620f712a15a1ff04f9ed6ed7150c02c14311",
            "unitOwner": "8",
            "countryJurisdictionOfOwner": "Argentina",
            "inCountryJurisdictionOfOwner": "Argentina",
            "serialNumberBlock": "8-9",
            "unitBlockStart": "8",
            "unitBlockEnd": "9",
            "unitCount": 1,
            "vintageYear": 2024,
            "unitType": "Reduction - nature",
            "marketplace": null,
            "marketplaceLink": null,
            "marketplaceIdentifier": null,
            "unitTags": null,
            "unitStatus": "Retired",
            "unitStatusReason": null,
            "unitRegistryLink": "https://chia.net",
            "correspondingAdjustmentDeclaration": "Unknown",
            "correspondingAdjustmentStatus": "Not Started",
            "timeStaged": "1715277490",
            "createdAt": "2024-05-09T18:01:51.714Z",
            "updatedAt": "2024-05-09T18:01:51.714Z",
            "labels": [],
            "issuance": null
        },```

Note `"issuance": null`.  If you take that exact record and issue a `PUT` to edit it, CADT will respond with `{"message":"Data Validation error","errors":["\"issuance\" must be of type object"],"success":false}`.  If it is not a required unit on initial insert, it should not be required upon editing the unit.