Skip to content

Commit

Permalink
Merge branch 'main' into AIP84-get-assets-queued-events-new
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsrahul1001 authored Nov 18, 2024
2 parents c263c61 + 6faa720 commit 9523dbc
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 227 deletions.
2 changes: 1 addition & 1 deletion airflow/api_connexion/endpoints/xcom_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_xcom_entry(
stub.value = XCom.deserialize_value(stub)
item = stub

if stringify or conf.getboolean("core", "enable_xcom_pickling"):
if stringify:
return xcom_schema_string.dump(item)

return xcom_schema_native.dump(item)
10 changes: 5 additions & 5 deletions airflow/api_fastapi/common/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from fastapi import Depends, HTTPException, Query
from pendulum.parsing.exceptions import ParserError
from pydantic import AfterValidator, BaseModel
from pydantic import AfterValidator, BaseModel, NonNegativeInt
from sqlalchemy import Column, case, or_
from sqlalchemy.inspection import inspect

Expand Down Expand Up @@ -66,7 +66,7 @@ def depends(self, *args: Any, **kwargs: Any) -> Self:
pass


class LimitFilter(BaseParam[int]):
class LimitFilter(BaseParam[NonNegativeInt]):
"""Filter on the limit."""

def to_orm(self, select: Select) -> Select:
Expand All @@ -75,19 +75,19 @@ def to_orm(self, select: Select) -> Select:

return select.limit(self.value)

def depends(self, limit: int = 100) -> LimitFilter:
def depends(self, limit: NonNegativeInt = 100) -> LimitFilter:
return self.set_value(limit)


class OffsetFilter(BaseParam[int]):
class OffsetFilter(BaseParam[NonNegativeInt]):
"""Filter on offset."""

def to_orm(self, select: Select) -> Select:
if self.value is None and self.skip_none:
return select
return select.offset(self.value)

def depends(self, offset: int = 0) -> OffsetFilter:
def depends(self, offset: NonNegativeInt = 0) -> OffsetFilter:
return self.set_value(offset)


Expand Down
34 changes: 34 additions & 0 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: tags
Expand Down Expand Up @@ -183,13 +185,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: uri_pattern
Expand Down Expand Up @@ -259,13 +263,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -611,13 +617,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -1055,13 +1063,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -1627,13 +1637,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -1681,13 +1693,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: tags
Expand Down Expand Up @@ -1799,13 +1813,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: tags
Expand Down Expand Up @@ -1911,13 +1927,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -2328,13 +2346,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -2427,13 +2447,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -2480,13 +2502,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
responses:
Expand Down Expand Up @@ -2684,13 +2708,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -2781,13 +2807,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
responses:
Expand Down Expand Up @@ -3023,13 +3051,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -3411,13 +3441,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down Expand Up @@ -3780,13 +3812,15 @@ paths:
required: false
schema:
type: integer
minimum: 0
default: 100
title: Limit
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
title: Offset
- name: order_by
Expand Down
2 changes: 1 addition & 1 deletion airflow/api_fastapi/core_api/routes/public/xcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_xcom_entry(
xcom_stub.value = XCom.deserialize_value(xcom_stub)
item = xcom_stub

if stringify or conf.getboolean("core", "enable_xcom_pickling"):
if stringify:
return XComResponseString.model_validate(item, from_attributes=True)

return XComResponseNative.model_validate(item, from_attributes=True)
9 changes: 0 additions & 9 deletions airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,6 @@ core:
type: string
example: ~
default: "False"
enable_xcom_pickling:
description: |
Whether to enable pickling for xcom (note that this is insecure and allows for
RCE exploits).
version_added: ~
type: string
example: ~
default: "False"
see_also: "https://docs.python.org/3/library/pickle.html#comparison-with-json"
allowed_deserialization_classes:
description: |
What classes can be imported during deserialization. This is a multi line value.
Expand Down
4 changes: 1 addition & 3 deletions airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3368,9 +3368,7 @@ def xcom_push(
Make an XCom available for tasks to pull.
:param key: Key to store the value under.
:param value: Value to store. What types are possible depends on whether
``enable_xcom_pickling`` is true or not. If so, this can be any
picklable object; only be JSON-serializable may be used otherwise.
:param value: Value to store. Only be JSON-serializable may be used otherwise.
"""
XCom.set(
key=key,
Expand Down
Loading

0 comments on commit 9523dbc

Please sign in to comment.