Skip to content

return {} on json parse error #29366

@shutaozhenzhen

Description

@shutaozhenzhen

Description

return JSON.parse(text) as Record<string, Provider>

The access to models.dev was blocked by my network environment and returned HTML, causing opencode to fail to start.
Suggestions:

If JSON parsing fails here, the accessed link or file should be explicitly printed in the logs
When JSON parsing fails, return {} instead of failing to start

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

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