Skip to content

Enhance upload behavior and validate labels and sources - #425

Open
fqrious wants to merge 3 commits into
mainfrom
enhancements-fixes
Open

Enhance upload behavior and validate labels and sources#425
fqrious wants to merge 3 commits into
mainfrom
enhancements-fixes

Conversation

@fqrious

@fqrious fqrious commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

closes #424
closes #423

@fqrious fqrious moved this from Todo to Pushed in Roadmap Aug 4, 2026
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
313 1 312 0
View the top 1 failed test(s) by shortest run time
../../../../../opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/schemathesis/generation/hypothesis/builder.py::test_api[PATCH /api/v1/files/{file_id}/]
Stack Traces | 13.1s run time
self = <django.db.backends.utils.CursorWrapper object at 0x7ffa83bad0d0>
sql = 'UPDATE "stixify_core_file" SET "name" = %s, "tlp_level" = %s, "pap_level" = NULL, "confidence" = NULL, "labels" = NUL...ification" = NULL, "txt2stix_data" = NULL, "sources" = NULL, "embedding_id" = NULL WHERE "stixify_core_file"."id" = %s'
params = ('First file, not special', 'red', datetime.datetime(2026, 8, 4, 12, 43, 25, 330720, tzinfo=datetime.timezone.utc), da...bda30e454/dcbeb240-8dd6-4892-8e9e-7b6bda30e454_file_FHX1PBs.md', 'identity--c5f27ca2-a580-4fee-9bb9-753e2b563a30', ...)
ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7ffa83bad0d0>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        # Raise a warning during app initialization (stored_app_configs is only
        # ever set during testing).
        if not apps.ready and not apps.stored_app_configs:
            warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
>               return self.cursor.execute(sql, params)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E               psycopg2.errors.NotNullViolation: null value in column "labels" of relation "stixify_core_file" violates not-null constraint
E               DETAIL:  Failing row contains (First file, not special, red, null, null, 2026-08-04 12:43:25.33072+00, 2026-08-04 12:43:37.818293+00, dcbeb240-8dd6-4892-8e9e-7b6bda30e454, identity--c5f27ca2-a580-4fee-9bb9-753e2b563a30/report--dcbeb240-..., , md, , null, 26fce5ea-c3df-45a2-8989-0225549c704b, null, null, null, null, , null, identity--c5f27ca2-a580-4fee-9bb9-753e2b563a30, null, null, null, null).

.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/backends/utils.py:105: NotNullViolation

The above exception was the direct cause of the following exception:

kwargs = {}

    @wraps(test_function)
>   def test_wrapper(*args: Any, **kwargs: Any) -> Any:
               ^^^^^^^^^^^

.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../generation/hypothesis/builder.py:178: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/st/test_schemathesis.py:57: in test_api
    case.call_and_validate(excluded_checks=[negative_data_rejection, positive_data_acceptance])
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../schemathesis/generation/case.py:210: in call
    response = transport_.send(
tests/utils.py:54: in send
    response: DRFResponse = client.generic(**serialized_request)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../django/test/client.py:671: in generic
    return self.request(**r)
           ^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../django/test/client.py:1090: in request
    self.check_exception(response)
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../django/test/client.py:805: in check_exception
    raise exc_value
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../core/handlers/exception.py:55: in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../core/handlers/base.py:197: in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../views/decorators/csrf.py:65: in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../site-packages/rest_framework/viewsets.py:125: in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11............/site-packages/rest_framework/views.py:515: in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11............/site-packages/rest_framework/views.py:475: in handle_exception
    self.raise_uncaught_exception(exc)
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11............/site-packages/rest_framework/views.py:486: in raise_uncaught_exception
    raise exc
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11............/site-packages/rest_framework/views.py:512: in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
stixify/web/views.py:348: in partial_update
    serializer.save()
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11....../site-packages/rest_framework/serializers.py:205: in save
    self.instance = self.update(self.instance, validated_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11....../site-packages/rest_framework/serializers.py:1035: in update
    instance.save()
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/models/base.py:902: in save
    self.save_base(
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/models/base.py:1008: in save_base
    updated = self._save_table(
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/models/base.py:1138: in _save_table
    updated = self._do_update(
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/models/base.py:1203: in _do_update
    return filtered._update(values) > 0
           ^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/models/query.py:1288: in _update
    return query.get_compiler(self.db).execute_sql(ROW_COUNT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../models/sql/compiler.py:2060: in execute_sql
    row_count = super().execute_sql(result_type)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../models/sql/compiler.py:1623: in execute_sql
    cursor.execute(sql, params)
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.backends.utils.CursorWrapper object at 0x7ffa83bad0d0>
sql = 'UPDATE "stixify_core_file" SET "name" = %s, "tlp_level" = %s, "pap_level" = NULL, "confidence" = NULL, "labels" = NUL...ification" = NULL, "txt2stix_data" = NULL, "sources" = NULL, "embedding_id" = NULL WHERE "stixify_core_file"."id" = %s'
params = ('First file, not special', 'red', datetime.datetime(2026, 8, 4, 12, 43, 25, 330720, tzinfo=datetime.timezone.utc), da...bda30e454/dcbeb240-8dd6-4892-8e9e-7b6bda30e454_file_FHX1PBs.md', 'identity--c5f27ca2-a580-4fee-9bb9-753e2b563a30', ...)
ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7ffa83bad0d0>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        # Raise a warning during app initialization (stored_app_configs is only
        # ever set during testing).
        if not apps.ready and not apps.stored_app_configs:
            warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
>               return self.cursor.execute(sql, params)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E               django.db.utils.IntegrityError: null value in column "labels" of relation "stixify_core_file" violates not-null constraint
E               DETAIL:  Failing row contains (First file, not special, red, null, null, 2026-08-04 12:43:25.33072+00, 2026-08-04 12:43:37.818293+00, dcbeb240-8dd6-4892-8e9e-7b6bda30e454, identity--c5f27ca2-a580-4fee-9bb9-753e2b563a30/report--dcbeb240-..., , md, , null, 26fce5ea-c3df-45a2-8989-0225549c704b, null, null, null, null, , null, identity--c5f27ca2-a580-4fee-9bb9-753e2b563a30, null, null, null, null).

.../hostedtoolcache/Python/3.11.15......................................................................................./x64/lib/python3.11.../db/backends/utils.py:105: IntegrityError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pushed

Development

Successfully merging this pull request may close these issues.

Prevent concurrent collection writes on arangodb Fix validations on file submissions

2 participants