question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to be able to access serialized data from changed object

See original GitHub issue

We need to be able to access a serialized dictionary of an object’s field values following a change. I’d like to add a serialized_data JSON field to the LogEntry model. That field will be populated by the receivers which will implement django.core.serializers to serialize the new state of the object after a change.

Having a historical record of object states will help us to be able to recover from several types of potential data loss events and aid us in debugging system artifacts. It is also critical to help us to determine calculated values for post hoc analysis and reporting. For example, if we need to determine who had x insurance and lived in y state at z time, we can use the audit log to determine what the person had listed as their state of residence at time z without needing a separate one to many historical model for state of residence.

There are a lot of helpful public facing APIs that could be added to the project using this field as a foundation (e.g., get_field_value_at_time(field_name, timestamp)) but the first step is to create the serialized_data field itself. Also note that I am aware there are other packages out there, such as django-reversions, that do this. However, in our experience they don’t fit our needs as a first-class audit log.

I am adding this functionality to our fork but would love it if you would consider adding it to the project. Please let me know if there is anything I can do to make that more likely. Look for my PR later today!

cc @hramezani

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rposbornecommented, Aug 8, 2022

Trust me I understand that ongoing maintenance and it’s impact in the OSS world and I thank you all deeply for the work that you do on this, and all the other projects you may work on. ❤️

Though, I do think that the saving of the serialized value can be considered low effort as long as Django itself is managing the serialization.

We are also happy to keep the surface area of the API smaller by removing things such as get_field_value_at_timestamp, if it removes some maintenance burden on you all.

1reaction
sum-rockcommented, Aug 8, 2022

@hramezani I figured the best way to show you my thoughts was in the PR. Take a look at what I’ve submitted and let me know what you all think. I’m happy to make changes if it has a better chance of getting merged!

Read more comments on GitHub >

github_iconTop Results From Across the Web

django - change the serialized data - Stack Overflow
You need to return the slug and not the blog post from the serializer ... obj): id = obj.object_id return BlogPost.objects.values('slug').get(id=id)['slug'].
Read more >
Serialization and Unserialization, C++ FAQ - Standard C++
What's this “serialization” thing all about? ¶ Δ. It lets you take an object or group of objects, put them on a disk...
Read more >
Serialization and deserialization in Java | Snyk Blog
Java serialization uses reflection to scrape all necessary data from the object's fields, including private and final fields.
Read more >
Remote code execution via serialized data - Red Hat
The simplest way to serialize and deserialize data safely is to use a format that does not include support for code objects.
Read more >
Everything You Need to Know About Java Serialization ...
The Transient and Static Fields Do Not Get Serialized ... If we want to serialize one object but do not want to serialize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found