Skip to content

Better handling of check expressions#3143

Draft
ryan-pratt wants to merge 3 commits intomainfrom
bug/check-undefined-tlm
Draft

Better handling of check expressions#3143
ryan-pratt wants to merge 3 commits intomainfrom
bug/check-undefined-tlm

Conversation

@ryan-pratt
Copy link
Copy Markdown
Contributor

@ryan-pratt ryan-pratt commented Apr 1, 2026

This is a potentially breaking change if users were abusing the check() API.

Before, if you booted fresh COSMOS with the demo and wrote a script with check(EXAMPLE STATUS VALUE > 1), then the script would crash (even in disconnect mode) because that tlm value is nil/None, which can't be compared using < or >. This fixes that by making sure the eval can be called before calling it and logging an error more gracefully. I also added some other safeguards around the comparisons you can do.

Also fixed a couple bugs in extract.py and added unit tests based on the ruby ones.

I gave up removing eval() because the code paths just became too numerous to keep in my head and I was spending too much time on it; plus like @/ryanmelt mentioned in standup, this is in an executing script anyway. I'd like to remove those, but it's tech debt for another time imo.

draft pr because it's late and idk yet if playwright will pass

…perator_and_operand_from_comparison

for removing eval in check() in next commit
so the script doesn't crash on undefined tlm
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.58%. Comparing base (38803d7) to head (cfbc13f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3143      +/-   ##
==========================================
- Coverage   78.23%   77.58%   -0.65%     
==========================================
  Files         673      471     -202     
  Lines       55239    34451   -20788     
  Branches      728      728              
==========================================
- Hits        43214    26728   -16486     
+ Misses      11947     7645    -4302     
  Partials       78       78              
Flag Coverage Δ
python 96.03% <ø> (+16.56%) ⬆️
ruby-api 83.25% <ø> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

Comment on lines +13 to +22
from openc3.utilities.extract import (
add_cmd_parameter,
extract_fields_from_cmd_text,
extract_fields_from_tlm_text,
extract_fields_from_set_tlm_text,
extract_fields_from_check_text,
extract_operator_and_operand_from_comparison,
remove_quotes,
convert_to_value,
)
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
15 New issues
1 Security Hotspot
8.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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