Skip to content

Conversation

@GDYendell
Copy link
Contributor

@GDYendell GDYendell commented Feb 2, 2026

Summary by CodeRabbit

  • New Features

    • String fields with configured maximum length now automatically truncate longer inputs to fit
    • String length validation enforces minimum length requirements at initialization
  • Tests

    • Added tests for string truncation and length validation behaviors

@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

String datatype now enforces minimum length validation and provides automatic truncation to configured maximum length. The EPICS transport layer updated to handle None length values by falling back to a default maximum. Tests added to verify truncation behavior across both layers.

Changes

Cohort / File(s) Summary
String Datatype Validation
src/fastcs/datatypes/string.py
Added __post_init__ runtime validation to enforce length >= 1. Introduced validate() method that truncates values to configured maximum length.
EPICS Transport Adaptation
src/fastcs/transports/epics/ca/util.py
Modified cast_to_epics_type to handle None length gracefully with fallback to DEFAULT_STRING_WAVEFORM_LENGTH for String datatype casting.
Validation Tests
tests/test_datatypes.py
Added tests verifying String truncation (length=10 truncates to 10 chars), no-length passthrough, and ValueError on zero-length constraint.
EPICS Casting Tests
tests/transports/epics/ca/test_ca_util.py
Updated test expectations for EPICS string truncation: inputs exceeding 256 characters now truncated to 256, and explicit length constraints applied in casting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A string with limits, now so fine,
Truncates with grace to length's line,
No None shall pass without a care,
Defaults step in, they're always there,
Validation springs with vigor bright! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Improve String validation' clearly summarizes the main change: adding validation logic to the String datatype class via new post_init and validate methods.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch string-validation

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.82%. Comparing base (a9db2b6) to head (a6fe650).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
+ Coverage   90.79%   90.82%   +0.02%     
==========================================
  Files          70       70              
  Lines        2543     2551       +8     
==========================================
+ Hits         2309     2317       +8     
  Misses        234      234              

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

Base automatically changed from setpoint-set-validation to main February 2, 2026 14:31
@GDYendell GDYendell merged commit 9967981 into main Feb 2, 2026
11 checks passed
@GDYendell GDYendell deleted the string-validation branch February 2, 2026 15:02
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