Skip to content

[Core Framework] Incorrect logical operator in _check_fields validation across multiple core modules #335

@Ronit-Raj9

Description

@Ronit-Raj9

What happened:

The _check_fields() methods across multiple core modules use and instead of or in their validation checks. This causes invalid inputs (e.g., empty strings, wrong types like integers) to silently pass validation instead of raising ValueError.

Affected Files (10 instances across 4 files):

File Field Line
core/cmd/obj/benchmarkingjob.py self.name L54
core/cmd/obj/benchmarkingjob.py self.test_object L61
core/storymanager/rank/rank.py self.sort_by L61
core/storymanager/rank/rank.py self.visualization L66
core/storymanager/rank/rank.py self.selected_dataitem L72
core/storymanager/rank/rank.py self.save_mode L87
core/testcasecontroller/algorithm/algorithm.py self.name L133
core/testcasecontroller/algorithm/algorithm.py self.paradigm_type L136
core/testcasecontroller/algorithm/module/module.py self.type L61
core/testcasecontroller/algorithm/module/module.py self.name L69

What you expected to happen:

The validation should use or so the error is raised when either condition fails:

# Current (incorrect) — raises error only when BOTH conditions are true
if not self.name and not isinstance(self.name, str):
    raise ValueError(...)

# Expected (correct) — raises error when EITHER condition is true
if not self.name or not isinstance(self.name, str):
    raise ValueError(...)

With and:

  • self.name = "" → no error raised ❌ (empty string is falsy but is a str, so second condition is False)
  • self.name = 123 → no error raised ❌ (not 123 is False, short-circuits)

With or:

  • self.name = "" → ✅ error raised (falsy)
  • self.name = 123 → ✅ error raised (not a string)
  • self.name = None → ✅ error raised (falsy)
  • self.name = "valid" → ✅ passes

How to reproduce it (as minimally and precisely as possible):

from core.cmd.obj.benchmarkingjob import BenchmarkingJob

# This should raise ValueError but doesn't due to the bug
config = {
    "name": 123,  # integer instead of string — passes validation incorrectly
    "workspace": "./workspace",
    "test_object": {"type": "algorithms", "algorithms": []}
}
job = BenchmarkingJob(config)

Anything else we need to know?:

  • The fix is a one-character change (andor) in each of the 10 locations listed above.
  • Without this fix, the framework silently accepts invalid configurations, leading to hard-to-debug runtime errors downstream during test case construction or ranking instead of failing fast at config validation time.
  • Environment: Python 3.8+, Linux (Fedora), main branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions