wojtek0806: @pjbreaux or @caphrim007 whenever it finishes testing please merge :)
diff --git a/f5/bigip/resource.py b/f5/bigip/resource.py
index 3bfcfec..018bfe1 100644
--- a/f5/bigip/resource.py
+++ b/f5/bigip/resource.py
@@ -100,6 +100,7 @@ from f5.bigip.mixins import LazyAttributeMixin
 from f5.bigip.mixins import ToDictMixin
 from f5.sdk_exception import F5SDKError
 from f5.sdk_exception import UnsupportedMethod
+from icontrol.exceptions import iControlUnexpectedHTTPError
 from requests.exceptions import HTTPError
 from six import iteritems
 from six import iterkeys
@@ -508,9 +509,18 @@ class ResourceBase(PathElement, ToDictMixin):
 
         data_dict.update(kwargs)
 
-        response = session.put(update_uri, json=data_dict, **requests_params)
-        self._meta_data = temp_meta
-        self._local_update(response.json())
+        # This is necessary as when we receive exception the returned object
+        # has its _meta_data stripped.
+
+        try:
+            response = session.put(update_uri, json=data_dict,
+                                   **requests_params)
+        except iControlUnexpectedHTTPError:
+                response = session.get(update_uri, **requests_params)
+                raise
+        finally:
+            self._meta_data = temp_meta
+            self._local_update(response.json())
 
     def update(self, **kwargs):
         """Update the configuration of the resource on the BIG-IP®.

factor other supported parameters and formats into iapp_parser
The iapp_parser util supports the common formats for iapps but does not support all of them, particularly those that are part of the iapp templates that F5 releases on downloads.f5.com
diff --git a/f5/bigip/test/unit/test_resource.py b/f5/bigip/test/unit/test_resource.py
index ed022d9..3ef0de4 100644
--- a/f5/bigip/test/unit/test_resource.py
+++ b/f5/bigip/test/unit/test_resource.py
@@ -47,6 +47,7 @@ from f5.bigip.tm.ltm.virtual import Policies_s
 from f5.bigip.tm.ltm.virtual import Profiles_s
 from f5.bigip.tm.ltm.virtual import Virtual
 from f5.sdk_exception import UnsupportedMethod
+from icontrol.exceptions import iControlUnexpectedHTTPError
 
 
 @pytest.fixture
@@ -330,6 +331,30 @@ class TestResource_update(object):
         assert pre_meta == r._meta_data
         assert r.raw == r.__dict__
 
+    def test_meta_data_exception_raised(self):
+        r = Resource(mock.MagicMock())
+        fake_session = mock.MagicMock(name='mock_session')
+        r._meta_data['allowed_lazy_attributes'] = []
+        r._meta_data['uri'] = 'URI'
+        text = 'Unexpected Error: Bad Request for uri: URI'
+        error_response = mock.MagicMock(name='error_mock')
+        error_response.status_code = 400
+        error_response.text = text
+        error = iControlUnexpectedHTTPError(response=error_response)
+        fake_session.get.return_value = MockResponse({u"generation": 0})
+        fake_session.put.side_effect = error
+        r._meta_data['bigip']._meta_data = {'icr_session': fake_session,
+                                            'hostname': 'TESTDOMAINNAME',
+                                            'uri':
+                                            'https://TESTDOMAIN:443/mgmt/tm/'}
+        pre_meta = r._meta_data.copy()
+        with pytest.raises(iControlUnexpectedHTTPError) as err:
+            r.update(a=u"b")
+        assert err.value.response.status_code == 400
+        assert err.value.response.text == text
+        assert pre_meta == r._meta_data
+        assert r.raw == r.__dict__
+
     def test_Collection_removal(self):
         r = Resource(mock.MagicMock())
         r._meta_data['allowed_lazy_attributes'] = []

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio pytest-bdd pytest-benchmark pytest-randomly responses mock hypothesis freezegun trustme requests-mock requests tomlkit
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==25.3.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
coverage==7.8.0
cryptography==44.0.2
exceptiongroup==1.2.2
execnet==2.1.1
f5-icontrol-rest==1.1.0
-e git+https://github.com/F5Networks/f5-common-python.git@adde820d63f53295a322e093df4438b17c9eeae1#egg=f5_sdk
freezegun==1.5.1
gherkin-official==29.0.0
hypothesis==6.130.6
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
Mako==1.3.9
MarkupSafe==3.0.2
mock==5.2.0
packaging==24.2
parse==1.20.2
parse_type==0.6.4
pluggy==1.5.0
py-cpuinfo==9.0.0
pycparser==2.22
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-bdd==8.1.0
pytest-benchmark==5.1.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
requests-mock==1.12.1
responses==0.25.7
six==1.17.0
sortedcontainers==2.4.0
tomli==2.2.1
tomlkit==0.13.2
trustme==1.2.1
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0

name: f5-common-python
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
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==25.3.0
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - cryptography==44.0.2
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - f5-icontrol-rest==1.1.0
      - freezegun==1.5.1
      - gherkin-official==29.0.0
      - hypothesis==6.130.6
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mako==1.3.9
      - markupsafe==3.0.2
      - mock==5.2.0
      - packaging==24.2
      - parse==1.20.2
      - parse-type==0.6.4
      - pluggy==1.5.0
      - py-cpuinfo==9.0.0
      - pycparser==2.22
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-bdd==8.1.0
      - pytest-benchmark==5.1.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-randomly==3.16.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - requests-mock==1.12.1
      - responses==0.25.7
      - six==1.17.0
      - sortedcontainers==2.4.0
      - tomli==2.2.1
      - tomlkit==0.13.2
      - trustme==1.2.1
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - zipp==3.21.0
prefix: /opt/conda/envs/f5-common-python

f5/bigip/test/unit/test_resource.py::TestResource_update::test_meta_data_exception_raised
f5/bigip/test/unit/test_resource.py::TestResource_load::test_URICreationCollision f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_reduce_boolean_same_value f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_success f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_reduce_boolean_removes_enabled f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_reduce_boolean_removes_disabled f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_reduce_boolean_removes_nothing f5/bigip/test/unit/test_resource.py::TestPathElement::test_check_command_parameters_fail f5/bigip/test/unit/test_resource.py::TestPathElement::test_check_load_parameters_fail f5/bigip/test/unit/test_resource.py::TestPathElement::test_check_create_parameters_fail f5/bigip/test/unit/test_resource.py::TestPathElement::test_check_exclusive_parameters_fail f5/bigip/test/unit/test_resource.py::TestAsmResource::test_load_uri_creation_collision f5/bigip/test/unit/test_resource.py::TestResource_update::test_reduce_boolean_same_value f5/bigip/test/unit/test_resource.py::TestStats::test_load f5/bigip/test/unit/test_resource.py::TestResource_modify::test_reduce_boolean_same_value f5/bigip/test/unit/test_resource.py::test_ResourceBase
f5/bigip/test/unit/test_resource.py::TestResource_load::test_requests_params_collision f5/bigip/test/unit/test_resource.py::TestResource_load::test_icontrol_version_set f5/bigip/test/unit/test_resource.py::TestResource_load::test_missing_required_params f5/bigip/test/unit/test_resource.py::TestResource_load::test_icontrol_version_default f5/bigip/test/unit/test_resource.py::TestResource_load::test_success f5/bigip/test/unit/test_resource.py::TestUnnamedResource::test_load f5/bigip/test/unit/test_resource.py::TestUnnamedResource::test_delete_raises f5/bigip/test/unit/test_resource.py::TestUnnamedResource::test_create_raises f5/bigip/test/unit/test_resource.py::TestResource_delete::test_invalid_force f5/bigip/test/unit/test_resource.py::TestResource_delete::test_success f5/bigip/test/unit/test_resource.py::TestCollection_get_collection::test_success f5/bigip/test/unit/test_resource.py::TestCollection_get_collection::test_unregistered_kind f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_KindTypeMismatch f5/bigip/test/unit/test_resource.py::TestResourceCreate::test_missing_required_creation_parameter f5/bigip/test/unit/test_resource.py::TestPathElement::test_check_exclusive_parameters_pass f5/bigip/test/unit/test_resource.py::TestPathElement::test_check_exclusive_parameters_empty_attr f5/bigip/test/unit/test_resource.py::TestPathElement::test_missing_req_param_false f5/bigip/test/unit/test_resource.py::TestPathElement::test_missing_req_param_true f5/bigip/test/unit/test_resource.py::TestAsmResource::test_exists_error f5/bigip/test/unit/test_resource.py::TestAsmResource::test_load_missing_required_params f5/bigip/test/unit/test_resource.py::TestAsmResource::test_exists_pop_name_id_uri f5/bigip/test/unit/test_resource.py::TestAsmResource::test_fetch f5/bigip/test/unit/test_resource.py::TestAsmResource::test_exists_not_found f5/bigip/test/unit/test_resource.py::TestAsmResource::test_update_raises f5/bigip/test/unit/test_resource.py::TestAsmResource::test_exists_loadable f5/bigip/test/unit/test_resource.py::TestAsmResource::test_load_success f5/bigip/test/unit/test_resource.py::TestAsmResource::test_load_pop_name_id_uri f5/bigip/test/unit/test_resource.py::TestAsmResource::test_delete_success f5/bigip/test/unit/test_resource.py::TestResource_update::test_Collection_removal f5/bigip/test/unit/test_resource.py::TestResource_update::test_reduce_boolean_removes_nothing f5/bigip/test/unit/test_resource.py::TestResource_update::test__meta_data_state f5/bigip/test/unit/test_resource.py::TestResource_update::test__check_generation_with_mismatch f5/bigip/test/unit/test_resource.py::TestResource_update::test_read_only_removal f5/bigip/test/unit/test_resource.py::TestResource_update::test_reduce_boolean_removes_disabled f5/bigip/test/unit/test_resource.py::TestResource_update::test_reduce_boolean_removes_enabled f5/bigip/test/unit/test_resource.py::TestStats::test_delete_raises f5/bigip/test/unit/test_resource.py::TestStats::test_modify_raises f5/bigip/test/unit/test_resource.py::TestStats::test_create_raises f5/bigip/test/unit/test_resource.py::TestResource_exists::test_not_found f5/bigip/test/unit/test_resource.py::TestResource_exists::test_error f5/bigip/test/unit/test_resource.py::TestResource_exists::test_loadable f5/bigip/test/unit/test_resource.py::TestResource_modify::test__meta_data_state f5/bigip/test/unit/test_resource.py::TestResource_modify::test_reduce_boolean_removes_disabled f5/bigip/test/unit/test_resource.py::TestResource_modify::test_read_only_validate f5/bigip/test/unit/test_resource.py::TestResource_modify::test_reduce_boolean_removes_enabled f5/bigip/test/unit/test_resource.py::TestResource_modify::test_Collection_removal f5/bigip/test/unit/test_resource.py::TestResource_modify::test_reduce_boolean_removes_nothing f5/bigip/test/unit/test_resource.py::test_Resource_refresh f5/bigip/test/unit/test_resource.py::test_Resource__local_update_IncompatibleKeys f5/bigip/test/unit/test_resource.py::test_Resource__local_update f5/bigip/test/unit/test_resource.py::test_Resource__check_keys_valid_rict f5/bigip/test/unit/test_resource.py::test__activate_URI_no_stats f5/bigip/test/unit/test_resource.py::test__create_with_Collision f5/bigip/test/unit/test_resource.py::test__activate_URI f5/bigip/test/unit/test_resource.py::test_OrganizingCollection f5/bigip/test/unit/test_resource.py::test_collection_s
f5/bigip/resource.py
f5/bigip/resource.py