Skip to content

Document next_flow in async_create_entry in RepairsFlow#2985

Open
iluvdata wants to merge 4 commits intohome-assistant:masterfrom
iluvdata:master
Open

Document next_flow in async_create_entry in RepairsFlow#2985
iluvdata wants to merge 4 commits intohome-assistant:masterfrom
iluvdata:master

Conversation

@iluvdata
Copy link

@iluvdata iluvdata commented Mar 7, 2026

Proposed change

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features for which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Remove stale or deprecated documentation

Checklist

  • I have read and followed the documentation guidelines.
  • I have verified that my changes render correctly in the documentation.

Additional information

Summary by CodeRabbit

  • Documentation
    • Added new guidance describing how repair flows can forward fixes into entry, config, options, and subentry reconfiguration flows, with illustrative examples.
    • Clarified that only the SOURCE_RECONFIGURE context is supported for next-flow transitions in config and subentry flows.
    • Included an example options flow and guidance discouraging repairs from initiating entirely new config/options/subentry flows.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d33af314-8a4a-4c75-9784-460ae1b35a41

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa79a1 and ea8b9cb.

📒 Files selected for processing (1)
  • docs/core/platform/repairs.md
✅ Files skipped from review due to trivial changes (1)
  • docs/core/platform/repairs.md

📝 Walkthrough

Walkthrough

Documentation added to docs/core/platform/repairs.md describing how repairs can forward control to entry, config, options, and subentry flows via next_flow (using FlowType and flow_id), including code examples and a note that next_flow is only supported with context source SOURCE_RECONFIGURE for CONFIG_FLOW and CONFIG_SUBENTRIES_FLOW.

Changes

Cohort / File(s) Summary
Documentation
docs/core/platform/repairs.md
Added ~71 lines documenting repair flow forwarding to entry/config/options/subentry flows, including code examples demonstrating next_flow usage with specific FlowType and flow_id, and a note restricting next_flow to SOURCE_RECONFIGURE for CONFIG_FLOW and CONFIG_SUBENTRIES_FLOW.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description follows the template with required sections completed (type of change selected, checklist items checked), but the 'Proposed change' section is empty with no explanation of the documentation changes. Complete the 'Proposed change' section to explain why this documentation addition is needed and what developers should understand about next_flow functionality.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main documentation addition about next_flow in async_create_entry within RepairsFlow, matching the core change in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
docs/core/platform/repairs.md (2)

136-136: Remove trailing whitespace.

Lines 136, 138, 160, and 162 have trailing whitespace after the commas. Consider removing these for cleaner formatting.

✨ Remove trailing spaces
-            return self.async_create_entry(
-                title="", data={}, 
-                next_flow=(
-                    FlowType.CONFIG_SUBENTRIES_FLOW, 
+            return self.async_create_entry(
+                title="", data={},
+                next_flow=(
+                    FlowType.CONFIG_SUBENTRIES_FLOW,
                     next_flow["flow_id"]
                 )
             )
-return self.async_create_entry(
-    title="", data={}, 
-    next_flow=(
-        FlowType.OPTIONS_FLOW,
+return self.async_create_entry(
+    title="", data={},
+    next_flow=(
+        FlowType.OPTIONS_FLOW,
         next_flow["flow_id"]
     )
 )

Also applies to: 138-138, 160-160, 162-162

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/core/platform/repairs.md` at line 136, Remove the trailing whitespace
after commas in the snippet shown (e.g. the "title=\"\", data={," fragment) on
the affected lines (136, 138, 160, 162); edit those lines to remove the extra
spaces immediately following the commas so they read without trailing spaces
(e.g. "title=\"\", data={}"). Ensure no other trailing spaces remain in the
surrounding lines.

103-103: Remove unused import.

ConfirmRepairFlow is imported on line 103 but not used in the code example. Consider removing it to keep the example focused.

🧹 Remove unused import
-from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
+from homeassistant.components.repairs import RepairsFlow
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/core/platform/repairs.md` at line 103, The import line currently
includes an unused symbol ConfirmRepairFlow; remove ConfirmRepairFlow from the
import so only the used RepairsFlow is imported (i.e., update the import that
reads "from homeassistant.components.repairs import ConfirmRepairFlow,
RepairsFlow" to import only RepairsFlow).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/core/platform/repairs.md`:
- Around line 153-166: The example uses the symbol ConfigFlowResult but it's not
imported; add an import for ConfigFlowResult from homeassistant.config_entries
in the module's imports so the options flow snippet (where async_init is called
and async_create_entry with next_flow is returned) will not raise a NameError.
- Around line 101-147: The example references SubentryFlowContext but does not
import it; add the missing import so the symbol is defined (e.g., import
SubentryFlowContext from the same module that provides subentry APIs) and ensure
the example's imports at the top include SubentryFlowContext so
Issue1RepairFlow.async_step_confirm can call SubentryFlowContext without a
NameError.
- Line 138: The explanatory text incorrectly references
FlowType.SUBENTRIES_FLOW; update that text to use the correct enum member
FlowType.CONFIG_SUBENTRIES_FLOW so it matches the code example (replace any
occurrence of FlowType.SUBENTRIES_FLOW in the explanatory paragraph with
FlowType.CONFIG_SUBENTRIES_FLOW).

---

Nitpick comments:
In `@docs/core/platform/repairs.md`:
- Line 136: Remove the trailing whitespace after commas in the snippet shown
(e.g. the "title=\"\", data={," fragment) on the affected lines (136, 138, 160,
162); edit those lines to remove the extra spaces immediately following the
commas so they read without trailing spaces (e.g. "title=\"\", data={}"). Ensure
no other trailing spaces remain in the surrounding lines.
- Line 103: The import line currently includes an unused symbol
ConfirmRepairFlow; remove ConfirmRepairFlow from the import so only the used
RepairsFlow is imported (i.e., update the import that reads "from
homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow" to
import only RepairsFlow).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09eba6b2-0c59-4c94-9758-e0b7e657dcf0

📥 Commits

Reviewing files that changed from the base of the PR and between 974c323 and 29e1d6e.

📒 Files selected for processing (1)
  • docs/core/platform/repairs.md

Updated context source description for next_flow issue repair flows.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/core/platform/repairs.md`:
- Around line 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.
- Around line 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f620fa80-3d80-4ab5-af81-f0209e897336

📥 Commits

Reviewing files that changed from the base of the PR and between 29e1d6e and 1aa79a1.

📒 Files selected for processing (1)
  • docs/core/platform/repairs.md

Comment on lines +101 to +147
```python
from homeassistant import data_entry_flow
from homeassistant.components.repairs import ConfirmRepairFlow, RepairsFlow
from homeassistant.config_entries import (
FlowType,
SOURCE_RECONFIGURE,
SubentryFlowContext,
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({})
)
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.

Comment on lines +154 to +167
```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"]
)
)
```
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.

@iluvdata
Copy link
Author

Retested with dev branch of frontend and next flow is no longer working even for config flows. The dialog is created then closed. There were many recent updates to ha-dialog.ts that appears to have broken this. Investigating a frontend patch.

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