jameinel: One small failing test, should be easy to fix:
```
ERROR: test_snapshot_saving_restricted_to_simple_types (test.test_framework.TestFramework)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/canonical/operator/test/test_framework.py", line 768, in test_snapshot_saving_restricted_to_simple_types

    class FooEvent(EventsBase):

NameError: name 'EventsBase' is not defined


```

diff --git a/ops/framework.py b/ops/framework.py
index c8df98b..edfe802 100755
--- a/ops/framework.py
+++ b/ops/framework.py
@@ -558,8 +558,18 @@ class Framework(Object):
             raise RuntimeError(
                 'cannot save {} values before registering that type'.format(type(value).__name__))
         data = value.snapshot()
-        # Use marshal as a validator, enforcing the use of simple types.
-        marshal.dumps(data)
+
+        # Use marshal as a validator, enforcing the use of simple types, as we later the
+        # information is really pickled, which is too error prone for future evolution of the
+        # stored data (e.g. if the developer stores a custom object and later changes its
+        # class name; when unpickling the original class will not be there and event
+        # data loading will fail).
+        try:
+            marshal.dumps(data)
+        except ValueError:
+            msg = "unable to save the data for {}, it must contain only simple types: {!r}"
+            raise ValueError(msg.format(value.__class__.__name__, data))
+
         # Use pickle for serialization, so the value remains portable.
         raw_data = pickle.dumps(data)
         self._storage.save_snapshot(value.handle.path, raw_data)

save_shapshot validation failures unhelpful
The following validation code is in save_snapshot() in framework.py:

```python
# Use marshal as a validator, enforcing the use of simple types.
marshal.dumps(data)
```

Unfortunately, when validation fails the charm developer is left with nothing but the useless traceback:
```
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-plinth-4/charm/hooks/db-relation-changed", line 499, in <module>
    ops.main.main(PlinthCharm)
  File "lib/ops/main.py", line 197, in main
    framework.commit()
  File "lib/ops/framework.py", line 496, in commit
    self.on.commit.emit()
  File "lib/ops/framework.py", line 199, in emit
    framework._emit(event)
  File "lib/ops/framework.py", line 633, in _emit
    self._reemit(event_path)
  File "lib/ops/framework.py", line 668, in _reemit
    custom_handler(event)
  File "lib/ops/framework.py", line 717, in on_commit
    self.framework.save_snapshot(self)
  File "lib/ops/framework.py", line 526, in save_snapshot
    marshal.dumps(data)
ValueError: unmarshallable object
```

As you can see, there is no context about what was being snapshotted, nor information about what bad data the object contained.

The unmarshallable exception needs to be caught, and a new one raised with more context so the developer can continue without hacking framework.py.
diff --git a/test/test_framework.py b/test/test_framework.py
index 1977c1e..fc64566 100644
--- a/test/test_framework.py
+++ b/test/test_framework.py
@@ -761,6 +761,26 @@ class TestFramework(unittest.TestCase):
         self.assertIn('database is locked', str(cm.exception))
         f.close()
 
+    def test_snapshot_saving_restricted_to_simple_types(self):
+        # this can not be saved, as it has not simple types!
+        to_be_saved = {"bar": TestFramework}
+
+        class FooEvent(EventSetBase):
+            def snapshot(self):
+                return to_be_saved
+
+        handle = Handle(None, "a_foo", "some_key")
+        event = FooEvent()
+
+        framework = self.create_framework()
+        framework.register_type(FooEvent, None, handle.kind)
+        with self.assertRaises(ValueError) as cm:
+            framework.save_snapshot(event)
+        expected = (
+            "unable to save the data for FooEvent, it must contain only simple types: "
+            "{'bar': <class 'test.test_framework.TestFramework'>}")
+        self.assertEqual(str(cm.exception), expected)
+
 
 class TestStoredState(unittest.TestCase):
 

pip install -e .
parse_log_pytest
pytest
PyYAML autopep8 flake8 pytest
git submodule update --init
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
autopep8==2.0.4
certifi==2021.5.30
flake8==2.5.5
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
mccabe==0.4.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
-e git+https://github.com/canonical/operator.git@02fe304edae9bce56f13cef32a2c48bdd150eb00#egg=ops
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pep8==1.7.1
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.10.0
pyflakes==1.0.0
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
PyYAML==6.0.1
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli==1.2.3
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: operator
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - autopep8==2.0.4
      - flake8==2.5.5
      - mccabe==0.4.0
      - pep8==1.7.1
      - pycodestyle==2.10.0
      - pyflakes==1.0.0
      - pyyaml==6.0.1
      - tomli==1.2.3
prefix: /opt/conda/envs/operator

test/test_framework.py::TestFramework::test_snapshot_saving_restricted_to_simple_types
test/test_framework.py::TestFramework::test_auto_register_event_types test/test_framework.py::TestFramework::test_bad_sig_observer test/test_framework.py::TestFramework::test_ban_concurrent_frameworks test/test_framework.py::TestFramework::test_conflicting_event_attributes test/test_framework.py::TestFramework::test_custom_event_data test/test_framework.py::TestFramework::test_defer_and_reemit test/test_framework.py::TestFramework::test_dynamic_event_types test/test_framework.py::TestFramework::test_event_key_roundtrip test/test_framework.py::TestFramework::test_events_base test/test_framework.py::TestFramework::test_forget_and_multiple_objects test/test_framework.py::TestFramework::test_forget_and_multiple_objects_with_load_snapshot test/test_framework.py::TestFramework::test_handle_attrs_readonly test/test_framework.py::TestFramework::test_handle_path test/test_framework.py::TestFramework::test_helper_properties test/test_framework.py::TestFramework::test_on_pre_commit_emitted test/test_framework.py::TestFramework::test_reemit_ignores_unknown_event_type test/test_framework.py::TestFramework::test_restore_unknown test/test_framework.py::TestFramework::test_simple_event_observer test/test_framework.py::TestFramework::test_snapshot_roundtrip test/test_framework.py::TestFramework::test_weak_observer test/test_framework.py::TestStoredState::test_basic_state_storage test/test_framework.py::TestStoredState::test_comparison_operations test/test_framework.py::TestStoredState::test_mutable_types test/test_framework.py::TestStoredState::test_mutable_types_invalid test/test_framework.py::TestStoredState::test_same_name_two_classes test/test_framework.py::TestStoredState::test_set_default test/test_framework.py::TestStoredState::test_set_operations test/test_framework.py::TestStoredState::test_straight_sub_subclass test/test_framework.py::TestStoredState::test_straight_subclass test/test_framework.py::TestStoredState::test_the_crazy_thing test/test_framework.py::TestStoredState::test_two_names_one_state test/test_framework.py::TestStoredState::test_two_subclasses test/test_framework.py::TestStoredState::test_two_subclasses_no_conflicts
ops/framework.py
ops/framework.py