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

Function validateInterceptionCursor

enterprise/coderd/aibridge.go:639–651  ·  view source on GitHub ↗

validateInterceptionCursor checks that a pagination cursor refers to an existing interception. When sessionID is non-empty the interception must also belong to that session. Returns errInvalidCursor on failure so callers can distinguish bad cursors from internal errors.

(ctx context.Context, db database.Store, cursorID uuid.UUID, cursorName, sessionID string)

Source from the content-addressed store, hash-verified

637// also belong to that session. Returns errInvalidCursor on failure so
638// callers can distinguish bad cursors from internal errors.
639func validateInterceptionCursor(ctx context.Context, db database.Store, cursorID uuid.UUID, cursorName, sessionID string) error {
640 if cursorID == uuid.Nil {
641 return nil
642 }
643 interception, err := db.GetAIBridgeInterceptionByID(ctx, cursorID)
644 if err != nil {
645 return xerrors.Errorf("%s: interception %s not found: %w", cursorName, cursorID, errInvalidCursor)
646 }
647 if sessionID != "" && interception.SessionID != sessionID {
648 return xerrors.Errorf("%s: interception %s does not belong to session %s: %w", cursorName, cursorID, sessionID, errInvalidCursor)
649 }
650 return nil
651}
652
653func populatedAndConvertAIBridgeInterceptions(ctx context.Context, db database.Store, dbInterceptions []database.ListAIBridgeInterceptionsRow) ([]codersdk.AIBridgeInterception, error) {
654 if len(dbInterceptions) == 0 {

Callers 2

Calls 2

ErrorfMethod · 0.45

Tested by

no test coverage detected