Skip to content

TEMPLATE_BASE64 and Fixes for STRUCTURE use#2846

Merged
ryanmelt merged 6 commits intomainfrom
template_base64
Feb 19, 2026
Merged

TEMPLATE_BASE64 and Fixes for STRUCTURE use#2846
ryanmelt merged 6 commits intomainfrom
template_base64

Conversation

@ryanmelt
Copy link
Copy Markdown
Member

No description provided.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 69.23077% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.72%. Comparing base (d22dbda) to head (bf2b967).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
openc3/lib/openc3/accessors/accessor.rb 0.00% 7 Missing ⚠️
openc3/lib/openc3/packets/packet.rb 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2846      +/-   ##
==========================================
+ Coverage   78.66%   78.72%   +0.06%     
==========================================
  Files         667      667              
  Lines       54452    54471      +19     
  Branches      731      731              
==========================================
+ Hits        42834    42883      +49     
+ Misses      11538    11508      -30     
  Partials       80       80              
Flag Coverage Δ
python 80.66% <ø> (+0.09%) ⬆️
ruby-api 80.26% <ø> (ø)
ruby-backend 82.07% <69.23%> (+0.06%) ⬆️

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.

if data_type == "STRING":
return ""
else:
return bytearray(b'')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the fix for the ProtoAccessor with a blank TEMPLATE

description: The template string which should be enclosed in quotes
values: "['\"].*['\"]"
since: 5.0.10
TEMPLATE_BASE64:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Allows for binary templates in the text config file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this if we already have the TEMPLATE_FILE which can be binary?

# Structure is used to write items with parent, not accessor
structure_buffer = read_item(item.parent_item, buffer)
structure = item.parent_item.structure
parent_item = @packet.get_item(item.parent_item)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Parent item changed from the actual item, to just the item name to lookup.
The new deep_copy in build_cmd() was copying the referenced item, and then not picking up bit_offset/bit_size dynamic changes.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
22.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

description: The template string which should be enclosed in quotes
values: "['\"].*['\"]"
since: 5.0.10
TEMPLATE_BASE64:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this if we already have the TEMPLATE_FILE which can be binary?

end
if self.parent_item
hash['parent_item'] = self.parent_item.as_json
hash['parent_item'] = self.parent_item
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will just be a string now right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes it is the parent item's name now, instead of a reference to the item itself.

if data_type == "STRING":
return ""
else:
return bytearray(b"")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

BLOCKs require a bytearray?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Python blocks are binary and therefore should always return a bytearray, not a string.

if @validator
config << " VALIDATOR #{@validator.class} #{@validator.args.map { |a| a.to_s.quote_if_necessary }.join(" ")}\n"
end
# TODO: Add TEMPLATE_ENCODED so this can always be done inline regardless of content
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lol I guess you were right!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep!

@ryanmelt
Copy link
Copy Markdown
Member Author

TEMPLATE_BASE64 is much more convenient than TEMPLATE_FILE as you can put the data in the same config file, rather than having to reference another file. File will still be useful for really big templates.

@ryanmelt ryanmelt merged commit f19b14e into main Feb 19, 2026
30 of 33 checks passed
@ryanmelt ryanmelt deleted the template_base64 branch February 19, 2026 03:56
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.

2 participants