Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions docs/core/platform/repairs.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,76 @@ async def async_create_fix_flow(
return Issue1RepairFlow()
```

### Issues that can be repaired via entry/options/subentry reconfiguration

Repair flows can forward issue fixes to config, options, or subentry flows:

```python
from homeassistant import data_entry_flow
from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
from homeassistant.config_entries import (
FlowType,
SOURCE_RECONFIGURE,
SubentryFlowResult,
)
from homeassistant.core import HomeAssistant



class Issue1RepairFlow(RepairsFlow):
"""Handler for an issue fixing flow."""

async def async_step_init(
self, user_input: dict[str, str] | None = None
) -> data_entry_flow.FlowResult:
return await (self.async_step_confirm())

async def async_step_confirm(
self, user_input: dict[str, str] | None = None
) -> data_entry_flow.FlowResult:
"""Handle the confirm step of a fix flow."""
if user_input is not None:
next_flow: SubentryFlowResult = (
await self.hass.config_entries.subentries.async_init(
(self.data["entry_id"], "subentry_type"),
context=SubentryFlowContext(
subentry_id=self.data["subentry_id"],
source=SOURCE_RECONFIGURE,
),
)
)
return self.async_create_entry(
title="", data={},
next_flow=(
FlowType.CONFIG_SUBENTRIES_FLOW,
next_flow["flow_id"]
)
)

return self.async_show_form(
step_id="confirm",
data_schema=vol.Schema({})
)
Comment on lines +101 to +147
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's find the file
find . -name "repairs.md" -path "*/docs/*" | head -20

Repository: home-assistant/developers.home-assistant

Length of output: 115


🏁 Script executed:

# Check the file size to understand what we're working with
wc -l docs/core/platform/repairs.md 2>/dev/null || echo "File not found at expected path"

Repository: home-assistant/developers.home-assistant

Length of output: 117


🏁 Script executed:

# Extract lines 101-150 from the file to verify the snippet
sed -n '101,150p' docs/core/platform/repairs.md

Repository: home-assistant/developers.home-assistant

Length of output: 1919


Add the missing import voluptuous as vol to this standalone example.

This code block uses vol.Schema({}) on line 146 without importing vol, making the example non-functional as written. The imports block at lines 102-109 is missing import voluptuous as vol, which is required by the vol.Schema({}) call.

Suggested fix
 ```python
+import voluptuous as vol
+
 from homeassistant import data_entry_flow
 from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
 from homeassistant.config_entries import (
     FlowType,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/core/platform/repairs.md` around lines 101 - 147, The example uses
vol.Schema({}) in Issue1RepairFlow.async_step_confirm but never imports
voluptuous; add the missing top-level import "import voluptuous as vol"
alongside the other imports so vol.Schema is defined and the async_step_confirm
return self.async_show_form call works correctly.

```

`context = {"source": SOURCE_RECONFIGURE}` is the only context source supported for `next_flow` issue repair flows for `FlowType.CONFIG_FLOW` and `FlowType.SUBENTRIES_FLOW`. Issue repairs should not be directing to new config/options/subentry flows (which cannot be broken if they do not exist).

#### Example options flow

```python
next_flow: ConfigFlowResult = (
await self.hass.config_entries.options.async_init(
config_entry.entry_id
)
)
return self.async_create_entry(
title="", data={},
next_flow=(
FlowType.OPTIONS_FLOW,
next_flow["flow_id"]
)
)
```
Comment on lines +154 to +167
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n docs/core/platform/repairs.md | sed -n '140,180p'

Repository: home-assistant/developers.home-assistant

Length of output: 1946


🏁 Script executed:

cat -n docs/core/platform/repairs.md | sed -n '100,170p'

Repository: home-assistant/developers.home-assistant

Length of output: 2746


🏁 Script executed:

cat -n docs/core/platform/repairs.md | sed -n '1,110p'

Repository: home-assistant/developers.home-assistant

Length of output: 5034


🏁 Script executed:

# Check if there's any documentation or code in the repository about RepairsFlow and self.config_entry
rg -A 5 "class RepairsFlow" --type python | head -50

Repository: home-assistant/developers.home-assistant

Length of output: 114


🏁 Script executed:

# Search for RepairsFlow class definition or documentation
rg "class RepairsFlow" -A 10 | head -60

Repository: home-assistant/developers.home-assistant

Length of output: 66


🏁 Script executed:

# Let me check the surrounding documentation to see if there's any mention of how config_entry should be accessed
cat -n docs/core/platform/repairs.md | sed -n '148,170p'

Repository: home-assistant/developers.home-assistant

Length of output: 884


🏁 Script executed:

# Search for any documentation about how to access config_entry in repairs context
rg "options.async_init" -B 5 -A 5 docs/

Repository: home-assistant/developers.home-assistant

Length of output: 634


Define the config entry ID before using it in the options-flow snippet.

config_entry is undefined in this example. The preceding example on the same page uses self.data["entry_id"] to access the config entry ID; this snippet should follow the same pattern for clarity and consistency.

Suggested fix
+config_entry_id = self.data["entry_id"]
 next_flow: ConfigFlowResult = (
     await self.hass.config_entries.options.async_init(
-        config_entry.entry_id
+        config_entry_id
     )
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/core/platform/repairs.md` around lines 154 - 167, The snippet uses an
undefined config_entry; change it to read the entry id from self.data (e.g.
assign config_entry_id = self.data["entry_id"]) and pass that id into
self.hass.config_entries.options.async_init instead of config_entry.entry_id,
then use the returned next_flow in the existing self.async_create_entry call
(keeping FlowType.OPTIONS_FLOW and next_flow["flow_id"]) so the example is
consistent with the earlier snippet.


## Issue life cycle

Expand Down