Skip to content

fix: Retrieving routine revision with zero valued input or empty time series external ID in the configuration#2470

Open
MortGron wants to merge 4 commits intomasterfrom
simint-retrieve-revision-with-zero-valued-input
Open

fix: Retrieving routine revision with zero valued input or empty time series external ID in the configuration#2470
MortGron wants to merge 4 commits intomasterfrom
simint-retrieve-revision-with-zero-valued-input

Conversation

@MortGron
Copy link
Contributor

@MortGron MortGron commented Feb 13, 2026

Description

client.simulators.routines.revisions.list or retrieve no longer returns a corrupted routine revision if the revision has a zero valued input or empty time series external ID in the configuration

Checklist:

  • Tests added/updated.
  • Documentation updated. Documentation is generated from docstrings - these must be updated according to your change.
    If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.
  • The PR title follows the Conventional Commit spec.

…returns a corrupted routine revision if the revision has a zero valued input in the configuration
@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@MortGron MortGron marked this pull request as ready for review February 13, 2026 22:49
@MortGron MortGron requested review from a team as code owners February 13, 2026 22:49
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.86%. Comparing base (e2f06c0) to head (5fa6b05).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2470   +/-   ##
=======================================
  Coverage   48.86%   48.86%           
=======================================
  Files         191      191           
  Lines       26152    26152           
=======================================
+ Hits        12778    12779    +1     
+ Misses      13374    13373    -1     
Files with missing lines Coverage Δ
...lient/data_classes/simulators/routine_revisions.py 45.70% <100.00%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MortGron
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug where a routine revision with a zero-valued input would be parsed incorrectly. The change ensures that the presence of the value field is checked instead of its truthiness. A unit test is added to cover this case. My review includes a suggestion to apply a similar fix for timeseries inputs to prevent a potential bug with empty sourceExternalId values, along with a corresponding test case.

MortGron and others added 2 commits February 14, 2026 08:43
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@MortGron MortGron changed the title fix: Retieving routine revision with zero valued input in the configuration fix: Retrieving routine revision with zero valued input or empty time series external ID in the configuration Feb 14, 2026
@MortGron
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in deserializing simulator routine revisions, specifically when an input has a zero value or a time series has an empty external ID. The fix correctly checks for the presence of keys rather than their truthiness, which is the right approach. The new tests validate this fix effectively. I have one suggestion to further improve the robustness of the deserialization logic by adding an explicit check for ambiguous inputs, which would make the client more resilient.

Comment on lines 84 to +86
is_constant = resource.get("value")
is_timeseries = resource.get("sourceExternalId")
type_ = "constant" if is_constant else "timeseries" if is_timeseries else None
type_ = "constant" if is_constant is not None else "timeseries" if is_timeseries is not None else None
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current logic correctly fixes the issue with falsy values. However, it silently gives precedence to value over sourceExternalId if both are present in the input dictionary. This could hide potential issues with the data source. To make the deserialization more robust, it would be better to explicitly check for this ambiguity and raise an error.

Suggested change
is_constant = resource.get("value")
is_timeseries = resource.get("sourceExternalId")
type_ = "constant" if is_constant else "timeseries" if is_timeseries else None
type_ = "constant" if is_constant is not None else "timeseries" if is_timeseries is not None else None
has_value = resource.get("value") is not None
has_source_external_id = resource.get("sourceExternalId") is not None
if has_value and has_source_external_id:
raise ValueError("Invalid routine input, cannot contain both 'value' and 'sourceExternalId'")
type_ = "constant" if has_value else "timeseries" if has_source_external_id else None
References
  1. The style guide recommends graceful error handling with meaningful error messages. The suggested change adds a validation check to prevent silent data misinterpretation and provides a clear error message if an ambiguous input is received. (link)

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.

1 participant