Skip to content

runtime error: index out of range error encountered sometimes when using sys.http.html2text #324

@sangee2004

Description

@sangee2004

Steps to reproduce the problem:

  1. Execute gptscript that uses sys.http.html2text along with search tool.
cat test_search_context.gpt
context: search_context from test_context.gpt with duckduckgo as search_tool
tools: github.com/gptscript-ai/search/duckduckgo, github.com/gptscript-ai/search/brave, sys.http.html2text?

What is today's weather in cupertino,California
cat test_context.gpt
name: search_context
export: sys.write
args: search_tool: tool to search with

#!/bin/bash
echo Search using ${search_tool}. Feel free to get the contents of the returned URLs in order to get more information. Provide as much detail as you can.Create a file with an appopriate name that represents the query and with contents of the search results
  1. Sometimes runtime error: index out of range error is encountered for sys.http.html2text tool call.
    panic: runtime error: index out of range [11] with length 11
goroutine 80 [running]:
github.com/olekukonko/tablewriter.(*Table).printFooter(0x140000fbc00)
	/Users/sangeethahariharan/go/pkg/mod/github.com/olekukonko/tablewriter@v0.0.6-0.20230925090304-df64c4bbad77/table.go:716 +0xa7c
github.com/olekukonko/tablewriter.(*Table).Render(0x140000fbc00)
	/Users/sangeethahariharan/go/pkg/mod/github.com/olekukonko/tablewriter@v0.0.6-0.20230925090304-df64c4bbad77/table.go:161 +0x90
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleTableElement(0x1400045de60, 0x1400037caf0)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:360 +0x8e0
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400037caf0)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:282 +0x600
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1?, 0x1400046c000?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x140001d61c0?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400037c9a0)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:213 +0x250
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1?, 0x1400045c020?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x1037406b8?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400037c850)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:213 +0x250
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1?, 0x1400045c3c0?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x1037406b8?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400037c7e0)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:213 +0x250
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1?, 0x1400045c760?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x1037406b8?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400035cfc0)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:299 +0x73c
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1400045cbc8?, 0x102e55424?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x102e559bc?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400032f3b0)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:299 +0x73c
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1400045cf68?, 0x140004bbf80?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x102e559bc?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x1400032ed90)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:299 +0x73c
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x1?, 0x1400045d240?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x1037406b8?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x1400045de60, 0x140002f2460)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:213 +0x250
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x140000176d8?, 0x102d43a50?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x102d4bf14?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x14000017e60, 0x140001fe770)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:299 +0x73c
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x10386ea40?, 0x0?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x10304d3b8?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).handleElement(0x14000017e60, 0x14000150770)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:299 +0x73c
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x0?, 0x0?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:420 +0x94
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverseChildren(0x1400045de60, 0x0?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:426 +0x40
github.com/jaytaylor/html2text.(*textifyTraverseContext).traverse(0x36dc?, 0x1400032a000?)
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:408 +0xa4
github.com/jaytaylor/html2text.FromHTMLNode(0x1038a3860?, {0x14000018000?, 0x0?, 0x0?})
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:77 +0x84
github.com/jaytaylor/html2text.FromReader({0x1038a3860?, 0x14000248720?}, {0x14000018000, 0x1, 0x1})
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:98 +0x78
github.com/jaytaylor/html2text.FromString({0x1400042a000?, 0x4?}, {0x14000018000, 0x1, 0x1})
	/Users/sangeethahariharan/go/pkg/mod/github.com/jaytaylor/html2text@v0.0.0-20230321000545-74c2419ad056/html2text.go:104 +0xf8
github.com/gptscript-ai/gptscript/pkg/builtin.SysHTTPHtml2Text({0x1038a9518?, 0x14000502300?}, {0x140003f2000?, 0x140000aa060?, 0x14000018078?}, {0x140002b40c0?, 0x140000aa060?})
	/Users/sangeethahariharan/gptscript/pkg/builtin/builtin.go:568 +0x6c
github.com/gptscript-ai/gptscript/pkg/builtin.Builtin.func1({0x1038a9518?, 0x14000502300?}, {0x140003f2000?, 0x5?, 0x140000180f8?}, {0x140002b40c0?, 0x103e22600?})
	/Users/sangeethahariharan/gptscript/pkg/builtin/builtin.go:234 +0x34
github.com/gptscript-ai/gptscript/pkg/engine.(*Engine).runCommand(_, {_, _}, {{{0x140002fa0c8, 0x12}, {0x103353121, 0x67}, 0x0, {0x1037ae88a, 0xb}, ...}, ...}, ...)
	/Users/sangeethahariharan/gptscript/pkg/engine/cmd.go:45 +0x2bc
github.com/gptscript-ai/gptscript/pkg/engine.(*Engine).Start(_, {{{0x140005006a0, 0x1d}, {{{...}, {...}, 0x0, {...}, 0x0, 0x0, 0x0, ...}, ...}, ...}, ...}, ...)
	/Users/sangeethahariharan/gptscript/pkg/engine/engine.go:192 +0x330
github.com/gptscript-ai/gptscript/pkg/runner.(*Runner).start(_, {{{0x140005006a0, 0x1d}, {{{...}, {...}, 0x0, {...}, 0x0, 0x0, 0x0, ...}, ...}, ...}, ...}, ...)
	/Users/sangeethahariharan/gptscript/pkg/runner/runner.go:407 +0x5e0
github.com/gptscript-ai/gptscript/pkg/runner.(*Runner).call(_, {{{0x140005006a0, 0x1d}, {{{...}, {...}, 0x0, {...}, 0x0, 0x0, 0x0, ...}, ...}, ...}, ...}, ...)
	/Users/sangeethahariharan/gptscript/pkg/runner/runner.go:355 +0x84
github.com/gptscript-ai/gptscript/pkg/runner.(*Runner).subCall(_, {_, _}, {{{0x103ccc788, 0x1}, {{{...}, {...}, 0x0, {...}, 0x0, ...}, ...}, ...}, ...}, ...)
	/Users/sangeethahariharan/gptscript/pkg/runner/runner.go:642 +0x180
github.com/gptscript-ai/gptscript/pkg/runner.(*Runner).subCalls.func1({0x1038a9550?, 0x140002da050?})
	/Users/sangeethahariharan/gptscript/pkg/runner/runner.go:716 +0xd0
github.com/gptscript-ai/gptscript/pkg/runner.(*parallelDispatcher).Run.func1()
	/Users/sangeethahariharan/gptscript/pkg/runner/parallel.go:51 +0x30
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/Users/sangeethahariharan/go/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go:78 +0x58
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
	/Users/sangeethahariharan/go/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go:75 +0x98

Note - On retry , this error is not seen and script is able to return the search results successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions