Bug 57728 - Kelvin/OxContext: 'NoneType' object has no attribute 'props'
Summary: Kelvin/OxContext: 'NoneType' object has no attribute 'props'
Status: CLOSED FIXED
Alias: None
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
Version: UCS@school 5.0
Hardware: Other Linux
: P5 normal
Target Milestone: UCS@school 5.0 v6-errata
Assignee: Johannes Königer
QA Contact: Ole Schwiegert
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-04 13:02 CET by Johannes Königer
Modified: 2024-11-21 16:19 CET (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.091
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Königer univentionstaff 2024-11-04 13:02:10 CET

    
Comment 2 Daniel Tröder univentionstaff 2024-11-05 07:36:19 CET
Please copy at least the traceback into Bugzilla, so it can be found when doing a full-text search.
Comment 4 Johannes Königer univentionstaff 2024-11-05 08:12:49 CET
The Traceback is:

```
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fastapi/applications.py", line 282, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/lib/python3.11/site-packages/timing_asgi/middleware.py", line 70, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/usr/lib/python3.11/site-packages/asgi_correlation_id/middleware.py", line 90, in __call__
    await self.app(scope, receive, handle_outgoing_request)
  File "/usr/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/usr/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fastapi/routing.py", line 241, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fastapi/routing.py", line 167, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/kelvin/kelvin-api/ucsschool/kelvin/routers/user.py", line 863, in create
    res = await user.create(udm)  # TODO: this takes 750 ms
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/kelvin/ucs-school-import/modules/ucsschool/importer/models/import_user.py", line 408, in create
    res = await super(ImportUser, self).create(  # TODO: this take 740 ms
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/user.py", line 278, in create
    return await super(User, self).create(lo=lo, validate=validate)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/base.py", line 621, in create
    await self.call_hooks(hook_time="pre", func_name="create", udm=lo)
  File "/kelvin/ucs-school-import/modules/ucsschool/importer/models/import_user.py", line 283, in call_hooks
    await func(self)
  File "/var/lib/ucs-school-import/kelvin-hooks/create_new_ox_contexts_kelvin.py", line 88, in _check_context
    val = getattr(self.default_context.props, prop)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'props'
```

This is the reproduced traceback, we did not have one from a customer system, the bug report contained only one line from the logs:

```
2024-08-28 08:56:00 ERROR [226][1d5c86602f] While responding to POST http://redacted.de/ucsschool/kelvin/v1/users/: 'NoneType' object has no attribute 'props'
```
Comment 5 Johannes Königer univentionstaff 2024-11-06 08:47:56 CET
The default context was never found because the context id from UDM, an integer, was compared to a string.

```
Package: ucs-school-import
Version: 18.0.53
Branch: 5.0-0
Scope: ucs-school-5.0
```
Comment 6 Johannes Königer univentionstaff 2024-11-21 16:19:09 CET
Errata updates for UCS@school 5.0 v6 have been released.

https://docs.software-univention.de/ucsschool-changelog/5.0v6/en/changelog.html#released-on-2024-11-21
https://docs.software-univention.de/ucsschool-changelog/5.0v6/de/changelog.html#released-on-2024-11-21

If this error occurs again, please clone this bug.