fix(brain): pass type and domain fields to ingestion write endpoint
The write handler was building a hand-rolled map that dropped the type and domain fields from writeArgs. Pass the struct directly so all fields reach the ingestion server. Strengthen the test to assert the request body contains the type field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,10 +56,7 @@ func (s *Skill) write(ctx context.Context, args json.RawMessage) (json.RawMessag
|
|||||||
if a.Content == "" {
|
if a.Content == "" {
|
||||||
return nil, fmt.Errorf("content is required")
|
return nil, fmt.Errorf("content is required")
|
||||||
}
|
}
|
||||||
return s.post(ctx, "/write", map[string]string{
|
return s.post(ctx, "/write", a)
|
||||||
"content": a.Content,
|
|
||||||
"filename": a.Filename,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Skill) post(ctx context.Context, path string, body any) (json.RawMessage, error) {
|
func (s *Skill) post(ctx context.Context, path string, body any) (json.RawMessage, error) {
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ func TestHandle_BrainQuery_CallsIngestServer(t *testing.T) {
|
|||||||
func TestHandle_BrainWrite_CallsIngestServer(t *testing.T) {
|
func TestHandle_BrainWrite_CallsIngestServer(t *testing.T) {
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
assert.Equal(t, "/write", r.URL.Path)
|
assert.Equal(t, "/write", r.URL.Path)
|
||||||
|
var body map[string]string
|
||||||
|
require.NoError(t, json.NewDecoder(r.Body).Decode(&body))
|
||||||
|
assert.Equal(t, "concept", body["type"])
|
||||||
|
assert.Equal(t, "# Test\n\nSome learning.", body["content"])
|
||||||
json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"})
|
json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"})
|
||||||
}))
|
}))
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user