MCPcopy Index your code
hub / github.com/coder/coder / getChatDebugRuns

Method getChatDebugRuns

coderd/exp_chats.go:7862–7892  ·  view source on GitHub ↗

getChatDebugRuns returns a list of debug run summaries for a chat. EXPERIMENTAL nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

7860//
7861//nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
7862func (api *API) getChatDebugRuns(rw http.ResponseWriter, r *http.Request) {
7863 ctx := r.Context()
7864 chat := httpmw.ChatParam(r)
7865
7866 const maxDebugRuns = 100
7867 runs, err := api.Database.GetChatDebugRunsByChatID(ctx, database.GetChatDebugRunsByChatIDParams{
7868 ChatID: chat.ID,
7869 LimitVal: maxDebugRuns,
7870 })
7871 if err != nil {
7872 // The chat may have been deleted or access revoked between
7873 // middleware extraction and this query (dbauthz re-authorizes
7874 // on read). Surface those races as 404 to match the rest of
7875 // this API and avoid leaking backend details.
7876 if httpapi.Is404Error(err) {
7877 httpapi.ResourceNotFound(rw)
7878 return
7879 }
7880 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
7881 Message: "Internal error fetching debug runs.",
7882 Detail: err.Error(),
7883 })
7884 return
7885 }
7886
7887 summaries := make([]codersdk.ChatDebugRunSummary, 0, len(runs))
7888 for _, run := range runs {
7889 summaries = append(summaries, db2sdk.ChatDebugRunSummary(run))
7890 }
7891 httpapi.Write(ctx, rw, http.StatusOK, summaries)
7892}
7893
7894// getChatDebugRun returns a single debug run with its steps.
7895// EXPERIMENTAL

Callers 1

chatDebugRunsFunction · 0.80

Calls 8

ChatParamFunction · 0.92
Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
ChatDebugRunSummaryFunction · 0.92
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected