Skip to content

[Bug]: Unchecked str.split() index access can raise IndexError #2745

@nidhi-singh02

Description

@nidhi-singh02

Description

Multiple locations access str.split()[0] without guarding against the case where split() returns an empty list (e.g., whitespace-only or empty strings). This causes an unhandled IndexError.

Affected Files

File Line Code
tools/file_operations.py 814 linter_cmd.split()[0]
gateway/platforms/slack.py 797 text.split()[0] if text else "" — doesn't handle whitespace-only text
agent/anthropic_adapter.py 79 result.stdout.strip().split()[0]

Steps to Reproduce

  1. In file_operations.py: configure a linter command as an empty string
  2. In slack.py: send a Slack message with only whitespace
  3. In anthropic_adapter.py: have claude --version return empty/whitespace output

Fix

Guard each split()[0] with a check that the resulting list is non-empty before indexing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt buildercomp/gatewayGateway runner, session dispatch, deliverycomp/toolsTool registry, model_tools, toolsetsplatform/slackSlack app adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions