{"record":{"id":"b291f79872843916","repo":"owasp-amass/amass","slug":"not-found","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"http","errorClass":"ErrNotFound","httpStatus":404,"severity":"error","filePath":"engine/api/server/v1/handlers.go","lineNumber":62,"sourceCode":"\ntype AddAssetResponse struct {\n\tEntityID string `json:\"entityID\"`\n}\n\n// Bulk typed add: {\"items\":[ <OAM obj>, <OAM obj>, ... ]}\n// where each item is arbitrary JSON object without \"type\".\ntype BulkAddAssetsRequest struct {\n\tItems []json.RawMessage `json:\"items\"`\n}\n\ntype BulkAddAssetsResponse struct {\n\tIngested int64 `json:\"ingested\"`\n\tStored   int64 `json:\"stored\"`\n\tFailed   int64 `json:\"failed\"`\n}\n\nvar (\n\tErrNotFound   = errors.New(\"not found\")\n\tErrBadRequest = errors.New(\"bad request\")\n)\n\ntype V1Handlers struct {\n\tctx context.Context\n\tlog *slog.Logger\n\tdis et.Dispatcher\n\tmgr et.SessionManager\n}\n\nfunc NewV1Handlers(ctx context.Context, dis et.Dispatcher, mgr et.SessionManager, log *slog.Logger) (*V1Handlers, error) {\n\treturn &V1Handlers{\n\t\tctx: ctx,\n\t\tlog: log,\n\t\tdis: dis,\n\t\tmgr: mgr,\n\t}, nil\n}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/api/server/v1/handlers.go#L44-L80","documentation":"ErrNotFound is the package-level sentinel for HTTP 404 responses in the v1 API handlers. Handlers return it (via writeError with http.StatusNotFound) when the requested resource — sessions list, session by token, stats, scope, or asset ingest targets — does not exist.","triggerScenarios":"Any v1 handler (ListSessions, TerminateSession, GetStats, GetScope, AddAssetTyped, AddAssetsBulk) finding no matching resource: mgr.GetSessions() is empty, mgr.GetSession(token) returns nil, or the referenced scope/session is missing.","commonSituations":"Calling the API with an expired or mistyped session token, querying before any sessions are created, or asking for a scope that was deleted or never registered.","solutions":["Verify the session token/scope identifier via ListSessions before calling.","Create/ingest a session before querying or terminating it.","Check the API base URL and path for typos.","Handle HTTP 404 in the client and surface a user-friendly 'resource not found' message."],"exampleFix":"// before\nsess := v.mgr.GetSession(token) // nil -> 404\nwriteError(w, http.StatusNotFound, \"session not found\", ErrNotFound)\n// after\nsess := v.mgr.GetSession(token)\nif sess == nil {\n    return fmt.Errorf(\"session %q does not exist; call ListSessions first\", token)\n}","handlingStrategy":"try-catch","validationCode":"sessions := client.ListSessions(ctx)\nif len(sessions) == 0 { return errors.New(\"no sessions available\") }\n// verify token exists before targeting it\nfound := false\nfor _, s := range sessions { if s.Token == token { found = true } }\nif !found { return fmt.Errorf(\"session %s not found\", token) }","typeGuard":null,"tryCatchPattern":"resp, err := client.Do(req)\nif err != nil { return err }\nif resp.StatusCode == http.StatusNotFound {\n    return fmt.Errorf(\"resource does not exist: %s\", req.URL)\n}","preventionTips":["List resources before referencing a specific token/scope.","Validate session tokens are still live (refresh/reconnect).","Use stable identifiers and keep them out of logs that get truncated.","Handle 404 distinctly from other errors in API clients."],"tags":["api","http","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}