Optional Fields are always coming back null when deployed on the IC. Locally, everything is working fine

I’m having an issue with an optional field that I recently added to my data structure. When I run my canisters locally, there no issue at all with this field. Everything functions properly, but once I deploy my canister to the IC, that same optional field is only ever coming back as null. is this a bug? can anyone confirm that their stable variables that feature optional fields are being stored properly on the IC?

Can you show those fields? For Example!!

@Jesse are you able to share the code involved if you haven’t already?

I’ve changed the code since posting this. I was on a time constraint and needed to resolve the matter sooner rather than later. I ended up making the field a required field as opposed to optional. And I did a reinstall on the canister. fortunately, it was just test data so I had the option to reinstall the canister. the lost data was merely test data, but this is an issue that I’m dreading for the future when I find myself needing to add a field to a stable variable in the prod canisters. Hopefully by then, the dfx teams has a solution for the issue of adding new fields to stable variables. and the solution doesn’t require me to copy the data, migrate it to another stable variable, then delete the old stable variable consisting of the old data structure. That method limits the amount of actual usable storage per canister.

1 Like