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:
- Start the Flask dashboard application
- Log in as a user with the dashboard role
- Navigate to the FIPS dashboard
- Open any chart that uses
year_from as its X-axis grouping field (e.g., FIPS Standard Migration Over Time)
- 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).
Describe the bug
FIPS charts that group by the
year_fromderived field fail at runtime with a MongoDB aggregation pipeline error. Theyear_fromfield uses a hardcoded reference to the Common Criteria date fieldnot_valid_before, which does not exist in FIPS documents. FIPS stores its certification date inweb_data.date_validation. When the pipeline attempts to extract a year from the missing field, MongoDB throws a$converterror.To Reproduce
Steps to reproduce the behavior:
year_fromas its X-axis grouping field (e.g.,FIPS Standard Migration Over Time)Expected behavior
FIPS charts using
year_fromshould extract the year fromweb_data.date_validation(the FIPS date field) and render correctly, the same way CC charts extract the year fromnot_valid_before.Desktop (please complete the following information):
pagebranchAdditional context
The root cause is that
DERIVED_FIELD_EXPRESSIONSinquery_builder.pyis a flat dictionary with a singleDerivedFieldDefinitionper derived field. There is no mechanism to provide collection-specific aggregation expressions. The fix restructures it into a nested dictionary keyed byCollectionName, with aresolve_derived_field(field, collection_name)helper that selects the correct variant per collection (or falls back to a collection-agnostic default).