Skip to content

No error handling when system-prompt points to file that does not exist #144

@StefMa

Description

@StefMa

I played around with this tool and added a system prompt pointing to a file systempromp.md.
I started the tool and everything "looked fine".
Until I realized, the system prompt wasn't really used.

The problem?
I had a typo in systempromp.md (spot the missing t 😉 ).
The file name is actually systemprompt.md

The "problem" is here:

func LoadSystemPrompt(input string) (string, error) {
if input == "" {
return "", nil
}
// Check if input is a file that exists
if _, err := os.Stat(input); err == nil {
// Read the entire file as plain text
content, err := os.ReadFile(input)
if err != nil {
return "", fmt.Errorf("error reading system prompt file: %v", err)
}
return strings.TrimSpace(string(content)), nil
}
// Treat as direct string
return input, nil
}

If os.Stat() returns an error, the tool assumes the input as text.
So the system prompt end up as systempromp.md 🫣 instead of the content of the correct file.

I'm not sure how to handle it better?
Maybe like curl, that requires a @ followed by the file path?
Or different options? system-prompt and system-prompt-file

💭

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions