Skip to content

[Bug] Logically impossible condition in updateTEViewData() prevents data updates #413

@mohityadav8

Description

@mohityadav8

Summary

The function updateTEViewData() in OsemosysClass.py contains a logically impossible condition when both TechId and EmisId are provided.

The current implementation checks whether the same dictionary key k equals both TechId and EmisId simultaneously:

if ((k == TechId if TechId is not None else True) and
    (k == EmisId if EmisId is not None else True)):
    obj[k] = value

A single key cannot equal two different values at the same time. Therefore, when both TechId and EmisId are not None, the condition always evaluates to False.
As a result, the assignment:
obj[k] = value
is never executed and the data is silently not updated.

Expected behavior

The method should correctly update the nested JSON structure by handling TechId and EmisId as separate nested keys instead of comparing both against the same variable k.

The update should occur when the correct nested path is matched.

Reproduction steps

Open the file:

Navigate to the method:
updateTEViewData()
Locate the conditional logic around line ~950:

if ((k == TechId if TechId is not None else True) and
    (k == EmisId if EmisId is not None else True)):

Call updateTEViewData() with both TechId and EmisId provided.

Example:

updateTEViewData(
    casename="example_case",
    ScId="Scenario1",
    GroupId="GroupA",
    ParamId="ParameterX",
    TechId="Tech1",
    EmisId="CO2",
    value=100
)

Observe that the condition never becomes True, so the assignment inside the block is never executed.

Environment

OS: Windows 11
Python version: 3.10
Branch: main

Logs or screenshots

The issue occurs due to the unreachable condition inside updateTEViewData() where a single key is compared against both TechId and EmisId.

Related work checked

No existing issues or pull requests addressing this logical condition were found.

Proposed track

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions