Skip to content

fix(expectations): tolerate null inject_expectation_signatures#315

Merged
RomuDeuxfois merged 1 commit into
mainfrom
fix/expectation-signatures-null-tolerance
Jul 21, 2026
Merged

fix(expectations): tolerate null inject_expectation_signatures#315
RomuDeuxfois merged 1 commit into
mainfrom
fix/expectation-signatures-null-tolerance

Conversation

@Seb-MIGUEL

Copy link
Copy Markdown
Contributor

Problem

The SentinelOne collector (and any collector polling detection/prevention expectations) stops processing with:

ERROR [CollectorExpectationManager] Error fetching expectations: 1 validation error for PreventionExpectation
inject_expectation_signatures
  Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]

The collector logs Fetched 0 expectations and never matches any alert.

Ref: OpenAEV-Platform/collectors#490

Root cause

Expectation.inject_expectation_signatures was declared as a required, non-nullable List[ExpectationSignature]. The platform serializes this field as null when an expectation has no computed signatures. Because expectations_models_for_source builds every model in a single loop, one such expectation raises a ValidationError that aborts the entire batch fetch — so even valid expectations are never returned.

Fix

  • inject_expectation_signatures now defaults to an empty list and a mode="before" validator coerces null[].
  • A single signature-less expectation is parsed as having no signatures instead of crashing the whole batch.

Tests

  • Added regression tests: null[], missing key → [], provided signatures preserved.
  • Full suite green (169 passed), black/isort clean, no new mypy errors on the changed file.

Note

This makes the client resilient to null signatures (stops the crash / batch abort). It does not by itself make alerts validate when signatures are genuinely empty — matching requires non-empty signatures, which is a platform-side concern (why signatures are null on the affected environment is being investigated separately).

The platform serializes inject_expectation_signatures as null when an
expectation has no computed signatures. The model required a list, so
parsing raised a ValidationError that aborted the entire expectation
batch fetch in collectors, leaving detection/prevention expectations
unprocessed (no alerts matched).

Coerce null to an empty list via a before-validator and default the
field to an empty list, so a signature-less expectation is parsed
instead of crashing the whole batch.

Refs: OpenAEV-Platform/collectors#490
Copilot AI review requested due to automatic review settings July 20, 2026 16:10
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. This PR is but one step away from being ready for merging: all commits must be PGP-signed. To get started, please see https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

Copilot AI 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.

Pull request overview

This PR makes the inject expectation models resilient to inject_expectation_signatures being serialized as null by coercing None → [], preventing a single malformed expectation from aborting batch expectation fetches (per collectors#490).

Changes:

  • Default Expectation.inject_expectation_signatures to an empty list via default_factory=list.
  • Add a Pydantic mode="before" field validator to coerce None signatures to [].
  • Add regression tests covering null → [], missing key defaulting to [], and preserving provided signatures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/apis/expectation/test_expectation.py Adds regression tests ensuring inject_expectation_signatures tolerates None/missing and preserves provided values.
pyoaev/apis/inject_expectation/model/expectation.py Implements None → [] coercion and defaults signatures to an empty list to prevent batch parsing failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@guzmud guzmud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@RomuDeuxfois
RomuDeuxfois merged commit d31a1dc into main Jul 21, 2026
13 of 16 checks passed
@RomuDeuxfois
RomuDeuxfois deleted the fix/expectation-signatures-null-tolerance branch July 21, 2026 05:37
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.

5 participants