Skip to content

fix(users): report Go zero time created_at as None for db users - #2244

Merged
dirkkul merged 3 commits into
weaviate:mainfrom
shadowmodder:shadowmodder/fix/users-db-created-at-zero-time
Nov 13, 2026
Merged

dirkkul merged 3 commits into
weaviate:mainfrom
shadowmodder:shadowmodder/fix/users-db-created-at-zero-time

Conversation

@shadowmodder

@shadowmodder shadowmodder commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2243

Summary

users.db.get() and list_all() passed the server's Go zero time (0001-01-01T00:00:00.000Z) through as created_at, so env-defined users came back with datetime(1, 1, 1) instead of None — even though UserDB.created_at is Optional[datetime] and the same response's lastUsedAt was already mapped to None.

What changed

  • Route createdAt through the zero-time helper in both get() and list_all() in weaviate/users/base.py.
  • Renamed the helper from _parse_last_used_at to _parse_optional_timestamp, since it now serves both fields.
  • Test coverage moved to the integration suite, per review: integration/test_users.py now asserts the env-defined admin-user's created_at is None in test_get_static_db_user (covers get()) and on its entry in test_list_all_users (covers list_all()), where the real server sends a zero-time createdAt. The earlier _FakeConnection mock tests in test/test_users.py are removed.

Test report

  • Integration: the two new assertions fail without the fix and pass with it (they need a live server, so they were not run locally).
  • Full unit suite: 564 passed, 1 skipped (pytest test/).
  • Lint: ruff check, ruff format --check, flake8 clean (pinned ruff 0.14.7).

@orca-security-eu orca-security-eu Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadowmodder nothing here blocks a merge from my side. With base.py from 7266681 both zero-time tests fail, and at the head an env user's created_at reads None while a real timestamp still parses.

$ python -m pytest -q -o addopts='' test/test_users.py   # head 65a2379, Python 3.12
6 passed, 1 warning in 1.35s

$ python -m pytest -q -o addopts='' test/   # head 65a2379
570 passed, 1 skipped, 39 warnings in 14.70s

# weaviate/users/base.py from 7266681, test/test_users.py kept
$ python -m pytest -q -o addopts='' test/test_users.py
5 failed, 1 passed, 1 warning in 1.09s   # 2 zero-time created_at tests, 3 ImportError on the renamed helper
# not run: mock_tests/, integration/, a live server at head

Both createdAt reads now share the helper, and no other client path parses that field.

On my question in the issue: I'd land this without waiting for #2216. Its fixes normalise an already parsed datetime in a pydantic validator, which a string helper does not fit.

@dirkkul

dirkkul commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

no CLA signed so we cannot merge this PR

@dirkkul dirkkul closed this Nov 13, 2026
@shadowmodder

Copy link
Copy Markdown
Contributor Author

I agree to the CLA

@shadowmodder

Copy link
Copy Markdown
Contributor Author

@dirkkul Apologies for the delay — I've now posted the CLA agreement above ("I agree to the CLA"). This was approved by chrikrah and the branch is unchanged. Could you reopen and merge when you get a chance? Thanks!

@dirkkul dirkkul reopened this Nov 13, 2026
Comment thread test/test_users.py Resolved
Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
…ion coverage

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
@dirkkul
dirkkul merged commit 8be3619 into weaviate:main Nov 13, 2026
126 of 127 checks passed
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.

users.db returns created_at as year 1 for an env-defined user, where last_used_time gives None

4 participants