Skip to content

Conversation

@andrew-codechimp
Copy link
Contributor

Proposed change

Raise translatable service validation errors
Pass the service call to _get_coordinator_from_service_data to remove duplicated code
Mark required fields within services.yaml, note the service remove_torrent has delete data set to required within yaml but is still optional (with default) within schema to allow existing automations to continue working.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @engrbm87, @JPHutchins, mind taking a look at this pull request as it has been labeled with an integration (transmission) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of transmission can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign transmission Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@andrew-codechimp andrew-codechimp marked this pull request as draft October 31, 2025 15:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the service error handling and validation in the Transmission integration by replacing generic exceptions with translatable service validation errors and standardizing the use of config entry ID constants.

Key changes:

  • Replaces HomeAssistantError with ServiceValidationError for better user-facing error messages
  • Adds translatable exception messages in strings.json
  • Standardizes config entry ID handling by using ATTR_CONFIG_ENTRY_ID instead of custom CONF_ENTRY_ID
  • Marks service fields as required in services.yaml

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
homeassistant/components/transmission/strings.json Adds translatable exception messages for service validation errors
homeassistant/components/transmission/services.yaml Marks all service fields as explicitly required
homeassistant/components/transmission/services.py Refactors error handling to use ServiceValidationError with translations and standardizes constant usage

add_torrent:
fields:
entry_id:
required: true
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Marking this field as required: true is redundant since it's already declared as vol.Required() in the Python service schema at line 33 of services.py. The Python schema validation takes precedence, and adding required: true in the YAML is unnecessary duplication. While not harmful, this redundancy should be removed for consistency with Home Assistant patterns, where required validation is typically handled only in the Python schema.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@andrew-codechimp andrew-codechimp Oct 31, 2025

Choose a reason for hiding this comment

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

These are marked as required as they don't show as mandatory on the UI otherwise and require a checkbox ticking.

remove_torrent:
fields:
entry_id:
required: true
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Marking this field as required: true is redundant since it's already declared as vol.Required() in the Python service schema at line 49 of services.py. The Python schema validation takes precedence, and adding required: true in the YAML is unnecessary duplication. While not harmful, this redundancy should be removed for consistency with Home Assistant patterns, where required validation is typically handled only in the Python schema.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

selector:
text:
delete_data:
required: true
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Marking this field as required: true is redundant since it's already declared with a default value (vol.Optional(ATTR_DELETE_DATA, default=DEFAULT_DELETE_DATA)) in the Python service schema at line 52 of services.py. Fields with default values are optional by nature, so adding required: true creates a contradiction between the YAML and Python definitions. This should be removed.

Suggested change
required: true

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

start_torrent:
fields:
entry_id:
required: true
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Marking this field as required: true is redundant since it's already declared as vol.Required() in the Python service schema at line 58 of services.py. The Python schema validation takes precedence, and adding required: true in the YAML is unnecessary duplication. While not harmful, this redundancy should be removed for consistency with Home Assistant patterns, where required validation is typically handled only in the Python schema.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

config_entry:
integration: transmission
id:
required: true
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Marking this field as required: true is redundant since it's already declared as vol.Required() in the Python service schema at line 58 of services.py. The Python schema validation takes precedence, and adding required: true in the YAML is unnecessary duplication. While not harmful, this redundancy should be removed for consistency with Home Assistant patterns, where required validation is typically handled only in the Python schema.

Suggested change
required: true

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

stop_torrent:
fields:
entry_id:
required: true
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Marking this field as required: true is redundant since it's already declared as vol.Required() in the Python service schema at line 62 of services.py. The Python schema validation takes precedence, and adding required: true in the YAML is unnecessary duplication. While not harmful, this redundancy should be removed for consistency with Home Assistant patterns, where required validation is typically handled only in the Python schema.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

@andrew-codechimp andrew-codechimp marked this pull request as ready for review October 31, 2025 15:55
@andrew-codechimp
Copy link
Contributor Author

Could I be cheeky and have #155213 reviewed/merged as well, it's slipped down the list and part of getting a quality scale rating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants