Skip to content

Conversation

@eifinger
Copy link
Contributor

Proposed change

Catch PermissionDenied exception returned when the new Routes API is not enabled.
Display a dedicated error message in the ConfigFlow during setup.
Create an issue for already existing integrations.

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

Checklist

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

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:

}
},
"error": {
"permission_denied": "The Routes API is not enabled for this API key.",
Copy link
Member

Choose a reason for hiding this comment

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

Can we add more context? Or do we have more context inthe descriptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There isn't enough space in the UI and the docs have everyhing: https://www.home-assistant.io/integrations/google_travel_time/#setup

Copy link
Member

Choose a reason for hiding this comment

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

But let's then at least explain a bit more and/or redirect the user to the docs. In my experience a lot of people mess up with google API access, so the clearer, the better (even though it might be a lot of text)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean a link in the error to the HomeAssistant docs in addition to the Button in the config flow UI? Or a phrase like "Please check the HA docs for this integration?"

Copy link
Member

Choose a reason for hiding this comment

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

I think just something that would explain to the user why their key failed and what they need to do. I don't expect a lot of people to understand that they're still doing something wrong so I think we can be more pointing to what they should be doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this? It feels redundant to me to add a link to docs if the button in the top right corner leads to them
grafik

Copy link
Member

Choose a reason for hiding this comment

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

Looks good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed it

"issues": {
"routes_api_disabled": {
"title": "The Routes API must be enabled",
"description": "Your Google Travel Time integration `{entry_title}` uses an API key which does not have the Routes API enabled.\n\n Please follow the instructions to [enable the API for your project](https://cloud.google.com/endpoints/docs/openapi/enable-api) and make sure your [API key restrictions](https://cloud.google.com/docs/authentication/api-keys#adding-api-restrictions) allow access to the Routes API.\n\n After enabling the API this issue will be resolved automatically."
Copy link
Member

Choose a reason for hiding this comment

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

links should be added as placeholders

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft May 27, 2025 15:54
@joostlek joostlek added this to the 2025.6.0 milestone May 27, 2025
@eifinger eifinger force-pushed the google_travel_time_routes_api_not_enabled branch from 38270a1 to 0eafa37 Compare May 27, 2025 16:12
@eifinger eifinger force-pushed the google_travel_time_routes_api_not_enabled branch from 0eafa37 to 0a31455 Compare May 27, 2025 16:41
@eifinger eifinger marked this pull request as ready for review May 27, 2025 16:42
@home-assistant home-assistant bot requested a review from joostlek May 27, 2025 16:42
@joostlek joostlek merged commit 481639b into home-assistant:dev May 27, 2025
34 checks passed
bramkragten pushed a commit that referenced this pull request May 27, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_travel_time needs Routes API enabled since 2025.5.0

3 participants