Skip to content

Fix hassfest validation: move URLs from translations to placeholders#249

Merged
danieldotnl merged 5 commits into
mainfrom
fix/hassfest-url-validation
Jan 31, 2026
Merged

Fix hassfest validation: move URLs from translations to placeholders#249
danieldotnl merged 5 commits into
mainfrom
fix/hassfest-url-validation

Conversation

@danieldotnl

@danieldotnl danieldotnl commented Jan 31, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes hassfest validation failures caused by URLs in translation strings.

Home Assistant PR #154224 (merged Jan 27, 2026) introduced validation that prevents URLs from being directly embedded in translation strings.

Changes

  • Updated translations/en.json to use placeholders ({buymeacoffee_url}, {device_class_url}, {state_class_url}) instead of hardcoded URLs
  • Added URL constants and placeholder functions in config_flow.py to inject URLs at runtime via description_placeholders
  • Fixed 3 unit tests in test_coordinator.py to pass hass parameter to Template constructor (now required in newer HA versions)

Testing

  • ✅ All 126 tests passing
  • ✅ Hassfest validation passing
  • ✅ HACS validation passing
  • ✅ URLs are displayed correctly to users via description placeholders

Related

  • Fixes validation failures reported in Home Assistant core issue #154226
  • Addresses changes from Home Assistant core PR #154224

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Updated development environment configuration with enhanced tooling support.
    • Updated test dependencies and improved template initialization for better test reliability.
  • Documentation

    • Improved configuration flow descriptions with clearer formatting and dynamic URL references.

✏️ Tip: You can customize this high-level summary in your review settings.

danieldotnl and others added 5 commits January 31, 2026 14:16
Home Assistant PR #154224 (merged Jan 27, 2026) introduced validation
that prevents URLs from being directly embedded in translation strings.

This commit implements the proper solution using description placeholders:
- Created strings.json with URL placeholders for form steps
- Added URL constants and placeholder functions in config_flow.py
- Updated SchemaFlowFormStep instances to inject URLs via description_placeholders
- Removed URLs from menu step descriptions (SchemaFlowMenuStep doesn't support placeholders)

This keeps the URLs maintainable in code while allowing translators to
work with clean, locale-agnostic strings.

Fixes hassfest validation failures reported in issue #154226

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Home Assistant now requires the hass parameter when creating Template
objects (will be mandatory in 2025.10). Updated three failing tests to
pass coordinator.hass to Template constructor.

Fixes test_start_with_counter, test_start_with_source, and test_start_with_time.

All 126 tests now passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Home Assistant now uses strings.json as the primary translation file.
The old translations/en.json with embedded URLs is no longer needed.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
strings.json is for core HA integrations. Custom integrations use
translations/en.json at runtime. URLs are removed from translations
and injected via description_placeholders in config_flow.py.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The placeholders {buymeacoffee_url}, {device_class_url}, and
{state_class_url} are now in the translation strings and will be
replaced with actual URLs by the description_placeholders functions
at runtime.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jan 31, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR updates the development container configuration with new features (Node 24, GitHub CLI, and Claude Code), refactors the MeasureIt component's config flow to use URL placeholders instead of hardcoded links, updates corresponding translations, bumps a test dependency version, and fixes template initialization in unit tests.

Changes

Cohort / File(s) Summary
Development Container
.devcontainer.json
Added devcontainer features for Node 24, GitHub CLI, and Anthropic Claude Code. Added bind mount for GitHub config directory. Updated postCreateCommand to include GitHub authentication setup.
Config Flow Placeholders
custom_components/measureit/config_flow.py, custom_components/measureit/translations/en.json
Introduced helper functions to provide URL placeholders (device_class_url, state_class_url, buymeacoffee_url) and wired them into configuration steps. Updated translations to reference these placeholders instead of hardcoded URLs.
Dependencies and Tests
requirements.txt, tests/unit/test_coordinator.py
Updated pytest-homeassistant-custom-component from 0.13.280 to 0.13.310. Fixed Template initialization in unit tests to pass Home Assistant instance for proper template binding.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Twitching nose with glee
Dev containers dance with Node's latest spree,
URLs transform to placeholders so neat,
Templates find their home, tests complete—
A bouncy refactor, both tidy and sweet! 🎉

✨ 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 fix/hassfest-url-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@danieldotnl danieldotnl merged commit 669c24d into main Jan 31, 2026
6 of 7 checks passed
@danieldotnl danieldotnl deleted the fix/hassfest-url-validation branch January 31, 2026 14:39
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