Skip to content

Set fallback timestamp to 0 if LDAP object lacks modifyTimestamp #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

DifanZhang
Copy link
Contributor

in ldapsources, the except block should not repeat the KeyError.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nss_cache/sources/ldapsource.py", line 745, in GetUpdates
    obj_ts = self.FromLdapToTimestamp(obj["modifyTimestamp"][0])
                                      ~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'modifyTimestamp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/nsscache", line 32, in <module>
    return_value = nsscache_app.Run(sys.argv[1:], os.environ)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/app.py", line 258, in Run
    retval = command_callable().Run(conf=conf, args=args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/command.py", line 246, in Run
    return self.UpdateMaps(
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/command.py", line 324, in UpdateMaps
    retval = updater.UpdateFromSource(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/update/updater.py", line 291, in UpdateFromSource
    return self.UpdateCacheFromSource(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/update/map_updater.py", line 73, in UpdateCacheFromSource
    source_map = source.GetMap(self.map_name, location=location)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/sources/source.py", line 66, in GetMap
    return self.GetPasswdMap(since)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/sources/ldapsource.py", line 472, in GetPasswdMap
    return PasswdUpdateGetter(self.conf).GetUpdates(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nss_cache/sources/ldapsource.py", line 747, in GetUpdates
    obj_ts = self.FromLdapToTimestamp(obj["modifyTimeStamp"][0])
                                      ~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'modifyTimeStamp'

This comment has been minimized.

@DifanZhang DifanZhang merged commit 7de6e18 into google:main Feb 20, 2025
6 checks passed
Copy link
Contributor

Unit Test Results

    1 files      1 suites   10s ⏱️
306 tests 300 ✔️ 6 💤 0 ❌

Results for commit 7de6e18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant