Skip to content

Field Year From is wrongly derived for FIPS data scheme #642

@xvalec01

Description

@xvalec01

Describe the bug
FIPS charts that group by the year_from derived field fail at runtime with a MongoDB aggregation pipeline error. The year_from field uses a hardcoded reference to the Common Criteria date field not_valid_before, which does not exist in FIPS documents. FIPS stores its certification date in web_data.date_validation. When the pipeline attempts to extract a year from the missing field, MongoDB throws a $convert error.

To Reproduce
Steps to reproduce the behavior:

  1. Start the Flask dashboard application
  2. Log in as a user with the dashboard role
  3. Navigate to the FIPS dashboard
  4. Open any chart that uses year_from as its X-axis grouping field (e.g., FIPS Standard Migration Over Time)
  5. The chart fails to render, and the server log shows: Field 'year_from' not found in data

Expected behavior
FIPS charts using year_from should extract the year from web_data.date_validation (the FIPS date field) and render correctly, the same way CC charts extract the year from not_valid_before.

Desktop (please complete the following information):

  • OS: Windows
  • Version of sec-certs: current page branch
  • Did you use dockerized sec-certs or Bare Python? Bare Python

Additional context
The root cause is that DERIVED_FIELD_EXPRESSIONS in query_builder.py is a flat dictionary with a single DerivedFieldDefinition per derived field. There is no mechanism to provide collection-specific aggregation expressions. The fix restructures it into a nested dictionary keyed by CollectionName, with a resolve_derived_field(field, collection_name) helper that selects the correct variant per collection (or falls back to a collection-agnostic default).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions