Skip to content

API Reference parrot.tools.dataset_manager.sources.scoped_copy

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.dataset_manager.sources.scoped_copy

View source

Request-scoped copies of :class:DataSource instances.

RLS injection must never mutate a source that outlives the request: the AuthorizingDataSource wrapper and the per-user DatasetManager clones both hold long-lived references, so an in-place rewrite leaks one subject's predicates into another subject's queries (issue:90cf04ce8edd).

Function request_scoped_copy

Return a copy of source that RLS injection may safely mutate.

A shallow copy is enough for every attribute the RLS injectors rebind (sql, required_filter), but inject_rls_table_source and inject_rls_query_slug write into _permanent_filter, so that dict is replaced with a fresh one. A deep copy is deliberately avoided: sources carry credentials objects and cached schema, which are expensive and sometimes impossible to deep-copy.

request_scoped_copy(source: DataSource) -> DataSource

Parameter Type Default Description
source DataSource The data source to isolate for the current request.

Returns: DataSource — A copy safe to mutate; source itself is left untouched.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally