Skip to content

fix(skills): prevent IndexError in build_plan_path on whitespace-only input - #7474

Closed
konsisumer wants to merge 3 commits into
NousResearch:mainfrom
konsisumer:fix/plan-slug-empty-splitlines
Closed

fix(skills): prevent IndexError in build_plan_path on whitespace-only input#7474
konsisumer wants to merge 3 commits into
NousResearch:mainfrom
konsisumer:fix/plan-slug-empty-splitlines

Conversation

@konsisumer

@konsisumer konsisumer commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • build_plan_path() crashes with IndexError when user_instruction is whitespace-only (e.g. " \n "), because .strip().splitlines() returns [] and then [0] is applied to the empty list.
  • Split the expression into two steps: compute lines first, then index only when non-empty.

Test plan

  • Pass whitespace-only string (" \n ") as user_instruction to build_plan_path — should return the default conversation-plan slug instead of crashing
  • Pass normal string — slug generation unchanged
  • Pass empty string / None — still returns default slug

Closes #7576

@konsisumer
konsisumer force-pushed the fix/plan-slug-empty-splitlines branch from 227de91 to 6b12569 Compare April 11, 2026 02:03
@konsisumer

Copy link
Copy Markdown
Contributor Author

Rebased onto latest origin/main and fixed the failing test_email_in_session_discovery test.

Root cause: Commit baddb6f7 (fix(gateway): derive channel directory platforms from enum instead of hardcoded list) refactored build_channel_directory() to iterate over the Platform enum dynamically instead of hardcoding platform names. The test used inspect.getsource() to check for a literal "email" string in the function body, which no longer exists.

Fix: Updated the test to verify that Platform contains "email" and that it's not in the _SKIP_SESSION_DISCOVERY frozenset — this guarantees email gets session-based discovery through the enum iteration.

… input

When user_instruction contains only whitespace, .strip().splitlines()
returns an empty list; indexing [0] on it raises IndexError.  Split
into two steps: compute lines first, then index only if non-empty.
…nputs

Cover the three test scenarios from the PR checklist:
- whitespace-only string returns default "conversation-plan" slug
- normal string slug generation is unchanged
- empty string and None both return default slug
@konsisumer
konsisumer force-pushed the fix/plan-slug-empty-splitlines branch from cb13542 to 6b9284c Compare April 17, 2026 10:31
@konsisumer

Copy link
Copy Markdown
Contributor Author

Closing: referenced_issue_closed. all referenced issues closed: [7576]


autocontrib · housekeeping · 2026-04-19T13:17:05Z

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.

[Bug]: IndexError in build_plan_path on whitespace-only input

1 participant