Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Return JSON response from syntax highlighter in presence of errors #62689

Open
Tracked by #59022
varungandhi-src opened this issue May 15, 2024 · 0 comments
Open
Tracked by #59022
Labels
bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. graph/syntax-highlighter Related to issues with syntax highlighting team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) tech-debt Technical Debt

Comments

@varungandhi-src
Copy link
Contributor

varungandhi-src commented May 15, 2024

The Rocket server we're using sometimes return HTML responses. In error cases, it should be possible to make it return JSON responses.

error: decoding JSON response from http://syntect-server:9238/: invalid character '<' looking for beginning of value

https://rocket.rs/guide/v0.5/requests/#built-in-catcher

The above docs make it sound like simply setting a header Accept: application/json should be good enough to do the trick. There is also a customization point here if needed: https://api.rocket.rs/v0.5/rocket/catcher/struct.Catcher

We should add an integration test to make sure we're returning JSON in the error case (Rocket docs on testing: https://rocket.rs/guide/v0.5/testing/). We should also make sure that the caller in gosyntect handles the error case properly (e.g. logging).

Related:

@varungandhi-src varungandhi-src added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) tech-debt Technical Debt graph/syntax-highlighter Related to issues with syntax highlighting labels May 15, 2024
@varungandhi-src varungandhi-src changed the title Incorrect HTML response from syntax highlighter in some cases Return JSON response from syntax highlighter in presence of errors May 15, 2024
@varungandhi-src varungandhi-src added the bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. label May 18, 2024 — with Linear
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. graph/syntax-highlighter Related to issues with syntax highlighting team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) tech-debt Technical Debt
Projects
None yet
Development

No branches or pull requests

1 participant