Skip to content

Unexpected KeyError while running test suite inside GitLab Worker #1236

Closed

Description

@konstista

Hello there, I'm looking for help.
Basically all of a sudden started getting unexpected KeyError while running test suite inside GitLab Worker.

It seems like no dependencies were updated, no extra code was recently added. Pipelines seem to fail even for the code that previously passed all tests. Interesting that everything works fine locally.

Error Trace

ImportError while loading conftest '.../tests/conftest.py'.
/usr/local/lib/python3.8/site-packages/ddtrace/internal/module.py:
[208](https://gitlab.com/.../jobs/...#L208): in _exec_module
    self.loader.exec_module(module)
tests/conftest.py:5: in <module>
    from service.main import app
...
...
...
service/utils.py:10: in <module>
    from jsonschema import validate
/usr/local/lib/python3.8/site-packages/ddtrace/internal/module.py:208: in _exec_module
    self.loader.exec_module(module)
/usr/local/lib/python3.8/site-packages/jsonschema/__init__.py:16: in <module>
    from jsonschema.validators import (
/usr/local/lib/python3.8/site-packages/ddtrace/internal/module.py:208: in _exec_module
    self.loader.exec_module(module)
/usr/local/lib/python3.8/site-packages/jsonschema/validators.py:589: in <module>
    meta_schema=SPECIFICATIONS.contents(
/usr/local/lib/python3.8/site-packages/referencing/_core.py:479: in contents
    return self._resources[uri.rstrip("#")].contents
E   KeyError: 'http://json-schema.org/draft-03/schema'

Error happens when importing validate() from jsonschema.
In all test cases the function is not being called, it fails on import.

Implementation

Implementation is fairly straightforward: try/except block wrapped in a function.

 try:
     validate(entity, schema)
     return True
 except Exception as e:
     return False

Dependencies

jsonschema==4.21.1
├── attrs [required: >=22.2.0, installed: 23.2.0]
├── jsonschema-specifications [required: >=2023.03.6, installed: 2023.12.1]
│   └── referencing [required: >=0.31.0, installed: 0.33.0]
│       ├── attrs [required: >=22.2.0, installed: 23.2.0]
│       └── rpds-py [required: >=0.7.0, installed: 0.18.0]
├── referencing [required: >=0.28.4, installed: 0.33.0]
│   ├── attrs [required: >=22.2.0, installed: 23.2.0]
│   └── rpds-py [required: >=0.7.0, installed: 0.18.0]
└── rpds-py [required: >=0.7.1, installed: 0.18.0]

Activity

  1. konstista commented on Mar 12, 2024

    @konstista
    Author

    The issue seems to be somewhere on my side, but I don't think something changed in the docker executor. The code itself is perfectly functional. Would be very appreciated for any help.

    I can overcome the issue with moving import to function local scope. As the function is never called in the test suite - the import never happens. But I'm just curious about the behaviour.

  2. silvanocerza commented on Mar 13, 2024

    @silvanocerza

    Same issue when running with Github runners. Locally it works without any issue.

  3. Julian commented on Mar 13, 2024

    @Julian
    Member

    There isn't enough info to be helpful I'm afraid. All passes here in CI in GitHub Actions without doing anything special. The error message points to you possibly doing something wrong to break normal installation of static (non-Python) files but hard to say what.

    (Going to convert this to a discussion. If there's more info there's a small chance I can help you figure it out but no promises.)

  4. locked and limited conversation to collaborators on Mar 13, 2024
  5. converted this issue into a discussion #1237 on Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions