Skip to content
Open

Test #44

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/error_scrape.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
jobs:
build:
permissions:
id-token: write
contents: write
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Revisit whether contents: write is the minimal permission needed for this workflow.

This change trades OIDC access for broader repo write access, which may exceed this job’s needs. If it only requires reading repo data, prefer contents: read. If you still need OIDC (e.g., to assume a cloud role), consider keeping id-token: write and adding only the minimal extra permissions required.

name: scrape-errors
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ def get_title_list(s: str) -> list:
fmt_keys = {}

for k, v in categories.items():
name, *bound_methods = get_title_list(v)
_name, *bound_methods = get_title_list(v)

fmt_keys.update(
{
Expand Down
31 changes: 31 additions & 0 deletions compiler/errors/source/400_BAD_REQUEST.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ BOT_GAMES_DISABLED Bot games cannot be used in this type of chat
BOT_GROUPS_BLOCKED This bot can't be added to groups
BOT_INLINE_DISABLED The inline feature of the bot is disabled
BOT_INVALID This is not a valid bot
BOT_INVOICE_INVALID The specified invoice is invalid.
BOT_METHOD_INVALID The method can't be used by bots
BOT_MISSING This method can only be run by a bot
BOT_NOT_CONNECTED_YET No [business bot](https://core.telegram.org/api/business#connected-bots) is connected to the currently logged in user.
Expand All @@ -60,10 +61,13 @@ BROADCAST_ID_INVALID The channel is invalid
BROADCAST_PUBLIC_VOTERS_FORBIDDEN Polls with public voters cannot be sent in channels
BROADCAST_REQUIRED The request can only be used with a channel
BUSINESS_PEER_INVALID Messages can't be set to the specified peer through the current [business connection](https://core.telegram.org/api/business#connected-bots).
BUSINESS_PEER_USAGE_MISSING You cannot send a message to a user through a [business connection](https://core.telegram.org/api/business#connected-bots) if the user hasn't recently contacted us.
BUSINESS_RECIPIENTS_EMPTY You didn't set any flag in inputBusinessBotRecipients, thus the bot cannot work with *any* peer.
BUSINESS_WORK_HOURS_EMPTY No work hours were specified.
BUSINESS_WORK_HOURS_PERIOD_INVALID The specified work hours are invalid, see [here »](https://core.telegram.org/api/business#opening-hours) for the exact requirements.
BUTTON_COPY_TEXT_INVALID The specified [keyboardButtonCopy](https://core.telegram.org/constructor/keyboardButtonCopy).`copy_text` is invalid.
BUTTON_DATA_INVALID The button callback data is invalid or too large
BUTTON_ID_INVALID The specified button ID is invalid.
BUTTON_POS_INVALID The position of one of the keyboard buttons is invalid (i.e. a Game or Pay button not in the first position, and so on...).
BUTTON_TEXT_INVALID The specified button text is invalid
BUTTON_TYPE_INVALID The type of one of the buttons you provided is invalid
Expand Down Expand Up @@ -93,6 +97,7 @@ CHARGE_NOT_FOUND The charge id was not found.
CHATLINKS_TOO_MUCH Too many [business chat links](https://core.telegram.org/api/business#business-chat-links) were created, please delete some older links.
CHATLINK_SLUG_EMPTY The specified slug is empty.
CHATLINK_SLUG_EXPIRED The specified [business chat link](https://core.telegram.org/api/business#business-chat-links) has expired.
CHATLISTS_TOO_MUCH You have created too many folder links, hitting the `chatlist_invites_limit_default`/`chatlist_invites_limit_premium` [limits »](https://core.telegram.org/api/config#chatlist-invites-limit-default).
CHATLIST_EXCLUDE_INVALID The specified `exclude_peers` are invalid.
CHAT_ABOUT_NOT_MODIFIED The chat about text was not modified because you tried to edit it using the same content
CHAT_ABOUT_TOO_LONG The chat about text is too long
Expand All @@ -104,6 +109,7 @@ CHAT_ID_INVALID The chat id being used is invalid or not known yet. Make sure yo
CHAT_INVALID The chat is invalid
CHAT_INVITE_PERMANENT The chat invite link is primary
CHAT_LINK_EXISTS The action failed because the supergroup is linked to a channel
CHAT_MEMBER_ADD_FAILED Could not add participants.
CHAT_NOT_MODIFIED The chat settings (title, permissions, photo, etc..) were not modified because you tried to edit them using the same content
CHAT_PUBLIC_REQUIRED You can only enable join requests in public groups.
CHAT_RESTRICTED The chat is restricted and cannot be used
Expand Down Expand Up @@ -166,6 +172,7 @@ ERROR_TEXT_EMPTY The provided error message is empty
EXPIRE_DATE_INVALID The expiration date is invalid
EXPIRE_FORBIDDEN Expire forbidden
EXPORT_CARD_INVALID The provided card is invalid
EXTENDED_MEDIA_AMOUNT_INVALID The specified `stars_amount` of the passed [inputMediaPaidMedia](https://core.telegram.org/constructor/inputMediaPaidMedia) is invalid.
EXTERNAL_URL_INVALID The external media URL is invalid
FIELD_NAME_EMPTY The field with the name FIELD_NAME is missing
FIELD_NAME_INVALID The field with the name FIELD_NAME is invalid
Expand All @@ -181,6 +188,7 @@ FILE_PART_LENGTH_INVALID The length of a file part is invalid
FILE_PART_SIZE_CHANGED The part size is different from the size of one of the previous parts in the same file
FILE_PART_SIZE_INVALID The file part size is invalid
FILE_PART_TOO_BIG The size limit for the content of the file part has been exceeded
FILE_PART_TOO_SMALL The size of the uploaded file part is too small, please see the documentation for the allowed sizes.
FILE_PART_X_MISSING Part {value} of the file is missing from storage
FILE_REFERENCE_EMPTY The file id contains an empty file reference, you must obtain a valid one by fetching the message from the origin context
FILE_REFERENCE_EXPIRED The file id contains an expired file reference, you must obtain a valid one by fetching the message from the origin context
Expand All @@ -197,7 +205,9 @@ FIRSTNAME_INVALID The first name is invalid
FOLDER_ID_EMPTY The folder you tried to delete was already empty
FOLDER_ID_INVALID The folder id is invalid
FORM_EXPIRED The form was generated more than 10 minutes ago and has expired, please re-generate it using [payments.getPaymentForm](https://core.telegram.org/method/payments.getPaymentForm) and pass the new `form_id`.
FORM_ID_EMPTY The specified form ID is empty.
FORM_ID_EXPIRED The specified id has expired.
FORM_UNSUPPORTED Please update your client.
FORUM_ENABLED You can't execute the specified action because the group is a [forum](https://core.telegram.org/api/forum), disable forum functionality to continue.
FRESH_CHANGE_ADMINS_FORBIDDEN You can't change administrator settings in this chat because your session was logged-in recently
FROM_MESSAGE_BOT_DISABLED Bots can't use fromMessage min constructors
Expand All @@ -223,6 +233,8 @@ GROUP_CALL_INVALID The group call is invalid
HASHTAG_INVALID The specified hashtag is invalid.
HASH_INVALID The provided hash is invalid
HIDE_REQUESTER_MISSING The join request was missing or was already handled
ID_EXPIRED The passed prepared inline message ID has expired.
ID_INVALID The passed ID is invalid.
IMAGE_PROCESS_FAILED The server failed to process your image
IMPORT_FILE_INVALID The imported file is invalid
IMPORT_FORMAT_DATE_INVALID The date specified in the import file is invalid.
Expand All @@ -238,6 +250,7 @@ INPUT_FILE_INVALID The specified [InputFile](https://core.telegram.org/type/Inpu
INPUT_FILTER_INVALID The filter is invalid for this query
INPUT_LAYER_INVALID The provided layer is invalid
INPUT_METHOD_INVALID The method invoked is invalid in the current schema
INPUT_PEERS_EMPTY The specified peer array is empty.
INPUT_REQUEST_TOO_LONG The input request is too long
INPUT_TEXT_EMPTY The specified text is empty
INPUT_TEXT_TOO_LONG The specified text is too long.
Expand All @@ -251,6 +264,7 @@ INVITE_REQUEST_SENT The request to join this chat or channel has been successful
INVITE_REVOKED_MISSING The action required a chat invite link to be revoked first
INVITE_SLUG_EMPTY The invite slug is empty
INVITE_SLUG_EXPIRED The invite slug is expired
INVITE_SLUG_INVALID The specified invitation slug is invalid.
INVOICE_PAYLOAD_INVALID The specified invoice payload is invalid
JOIN_AS_PEER_INVALID The specified peer cannot be used to join a group call
LANGUAGE_INVALID The specified lang_code is invalid.
Expand Down Expand Up @@ -326,6 +340,7 @@ PEER_FLOOD The method can't be used because your account is currently limited
PEER_HISTORY_EMPTY Peer history empty
PEER_ID_INVALID The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it
PEER_ID_NOT_SUPPORTED The provided peer id is not supported
PEER_TYPES_INVALID The passed [keyboardButtonSwitchInline](https://core.telegram.org/constructor/keyboardButtonSwitchInline).`peer_types` field is invalid.
PERSISTENT_TIMESTAMP_EMPTY The pts argument is empty
PERSISTENT_TIMESTAMP_INVALID The persistent timestamp is invalid
PHONE_CODE_EMPTY The phone code is missing
Expand Down Expand Up @@ -363,6 +378,7 @@ POLL_QUESTION_INVALID The poll question is invalid
POLL_UNSUPPORTED This layer does not support polls in the invoked method
POLL_VOTE_REQUIRED Cast a vote in the poll before calling this method
PREMIUM_ACCOUNT_REQUIRED The method requires a premium user account
PRICING_CHAT_INVALID The pricing for the [subscription](https://core.telegram.org/api/subscriptions) is invalid, the maximum price is specified in the [`stars_subscription_amount_max` config key »](https://core.telegram.org/api/config#stars-subscription-amount-max).
PRIVACY_KEY_INVALID The privacy key is invalid
PRIVACY_TOO_LONG Your privacy exception list has exceeded the maximum capacity
PRIVACY_VALUE_INVALID The privacy value is invalid
Expand Down Expand Up @@ -432,8 +448,17 @@ SLOWMODE_MULTI_MSGS_DISABLED Slowmode is enabled, you cannot forward multiple me
SLUG_INVALID The specified invoice slug is invalid.
SMSJOB_ID_INVALID The specified job ID is invalid.
SMS_CODE_CREATE_FAILED An error occurred while creating the SMS code
SRP_A_INVALID The specified inputCheckPasswordSRP.A value is invalid.
SRP_ID_INVALID Invalid SRP ID provided
SRP_PASSWORD_CHANGED The password has changed
STARGIFT_INVALID The passed [inputInvoiceStarGift](https://core.telegram.org/constructor/inputInvoiceStarGift) is invalid.
STARGIFT_USAGE_LIMITED The gift is sold out.
STARREF_AWAITING_END The previous referral program was terminated less than 24 hours ago: further changes can be made after the date specified in userFull.starref_program.end_date.
STARREF_HASH_REVOKED The specified affiliate link was already revoked.
STARREF_PERMILLE_INVALID The specified commission_permille is invalid: the minimum and maximum values for this parameter are contained in the [starref_min_commission_permille](https://core.telegram.org/api/config#starref-min-commission-permille) and [starref_max_commission_permille](https://core.telegram.org/api/config#starref-max-commission-permille) client configuration parameters.
STARREF_PERMILLE_TOO_LOW The specified commission_permille is too low: the minimum and maximum values for this parameter are contained in the [starref_min_commission_permille](https://core.telegram.org/api/config#starref-min-commission-permille) and [starref_max_commission_permille](https://core.telegram.org/api/config#starref-max-commission-permille) client configuration parameters.
STARS_INVOICE_INVALID The specified Telegram Star invoice is invalid.
STARS_PAYMENT_REQUIRED To import this chat invite link, you must first [pay for the associated Telegram Star subscription »](https://core.telegram.org/api/subscriptions#channel-subscriptions).
START_PARAM_EMPTY The start parameter is empty
START_PARAM_INVALID The start parameter is invalid
START_PARAM_TOO_LONG The start parameter is too long
Expand Down Expand Up @@ -466,17 +491,21 @@ STORY_NOT_MODIFIED The new story information you passed is equal to the previous
STORY_PERIOD_INVALID The story period is invalid
STORY_SEND_FLOOD_MONTHLY_X You've hit the monthly story limit as specified by the [`stories_sent_monthly_limit_*` client configuration parameters](https://core.telegram.org/api/config#stories-sent-monthly-limit-default): wait for the specified number of seconds before posting a new story.
STORY_SEND_FLOOD_WEEKLY_X You've hit the weekly story limit as specified by the [`stories_sent_weekly_limit_*` client configuration parameters](https://core.telegram.org/api/config#stories-sent-weekly-limit-default): wait for the specified number of seconds before posting a new story.
SUBSCRIPTION_EXPORT_MISSING You cannot send a [bot subscription invoice](https://core.telegram.org/api/subscriptions#bot-subscriptions) directly, you may only create invoice links using [payments.exportInvoice](https://core.telegram.org/method/payments.exportInvoice).
SUBSCRIPTION_PERIOD_INVALID The specified subscription_pricing.period is invalid.
SWITCH_PM_TEXT_EMPTY The switch_pm.text field was empty
SWITCH_WEBVIEW_URL_INVALID The URL specified in switch_webview.url is invalid!
TAKEOUT_INVALID The takeout id is invalid
TAKEOUT_REQUIRED The method must be invoked inside a takeout session
TASK_ALREADY_EXISTS An email reset was already requested.
TEMP_AUTH_KEY_ALREADY_BOUND The passed temporary key is already bound to another perm_auth_key_id
TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty
TERMS_URL_INVALID The specified [invoice](https://core.telegram.org/constructor/invoice).`terms_url` is invalid.
THEME_FILE_INVALID Invalid theme file provided
THEME_FORMAT_INVALID Invalid theme format provided
THEME_INVALID Invalid theme provided
THEME_MIME_INVALID You cannot create this theme because the mime-type is invalid
THEME_PARAMS_INVALID The specified `theme_params` field is invalid.
THEME_TITLE_INVALID The specified theme title is invalid
TIMEZONE_INVALID The specified timezone does not exist.
TITLE_INVALID The specified stickerpack title is invalid
Expand All @@ -494,6 +523,7 @@ TOPIC_ID_INVALID The provided topic ID is invalid
TOPIC_NOT_MODIFIED The topic was not modified
TOPIC_TITLE_EMPTY The specified topic title is empty.
TO_LANG_INVALID The specified destination language is invalid
TRANSACTION_ID_INVALID The specified transaction ID is invalid.
TRANSCRIPTION_FAILED Telegram is having internal problems. Please try again later to transcribe the audio.
TRANSLATE_REQ_QUOTA_EXCEEDED Translation is currently unavailable due to a temporary server-side lack of resources.
TTL_DAYS_INVALID The provided TTL days is invalid
Expand Down Expand Up @@ -524,6 +554,7 @@ USER_BOT_INVALID This method can only be used by a bot
USER_BOT_REQUIRED The method can be used by bots only
USER_CHANNELS_TOO_MUCH The user is already in too many channels or supergroups
USER_CREATOR You can't leave this channel because you're its creator
USER_GIFT_UNAVAILABLE Gifts are not available in the current region ([stars_gifts_enabled](https://core.telegram.org/api/config#stars-gifts-enabled) is equal to false).
USER_ID_INVALID The user id being used is invalid or not known yet. Make sure you meet the user before interacting with it
USER_INVALID The provided user is invalid
USER_IS_BLOCKED The user blocked you
Expand Down
2 changes: 2 additions & 0 deletions compiler/errors/source/403_FORBIDDEN.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CHAT_SEND_ROUNDVIDEOS_FORBIDDEN You can't send round videos to this chat.
CHAT_SEND_STICKERS_FORBIDDEN You can't send stickers in this chat
CHAT_SEND_VIDEOS_FORBIDDEN You can't send videos in this chat
CHAT_SEND_VOICES_FORBIDDEN You can't send voice recordings in this chat
CHAT_TYPE_INVALID The specified user type is invalid.
CHAT_WRITE_FORBIDDEN You can't write in this chat
EDIT_BOT_INVITE_FORBIDDEN Bots' chat invite links can't be edited
GROUPCALL_ALREADY_STARTED The groupcall has already started, you can join directly using phone.joinGroupCall
Expand All @@ -31,6 +32,7 @@ MESSAGE_DELETE_FORBIDDEN You don't have rights to delete messages in this chat,
NOT_ALLOWED Not allowed
NOT_ELIGIBLE You are not eligible for this action
PARTICIPANT_JOIN_MISSING Trying to enable a presentation, when the user hasn't joined the Video Chat with phone.joinGroupCall
PEER_ID_INVALID The provided peer id is invalid.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Adding the PEER_ID_INVALID error ID here introduces a name collision with an existing error. This ID is already defined in compiler/errors/source/400_BAD_REQUEST.tsv.

The error compiler (compiler/errors/compiler.py) generates Python exception class names by converting the error ID to CamelCase. In this case, both PEER_ID_INVALID entries will be converted to a class named PeerIdInvalid.

During the build process, the __init__.py file in the exceptions directory imports all classes from the generated modules (e.g., from .bad_request_400 import *, from .forbidden_403 import *). This will cause one of the PeerIdInvalid class definitions to overwrite the other, depending on the import order. This can lead to incorrect exception types being raised at runtime. For example, an error with code 403 might be raised as a subclass of BadRequest (400).

To resolve this, you should either ensure that error IDs are unique across all TSV files or modify the compiler to generate unique class names (e.g., by prefixing them with the error type like ForbiddenPeerIdInvalid). Since the error IDs seem to come directly from the Telegram API, modifying the compiler is likely the correct approach to handle these collisions systematically.

POLL_VOTE_REQUIRED Cast a vote in the poll before calling this method
PREMIUM_ACCOUNT_REQUIRED This action requires a premium account
PRIVACY_PREMIUM_REQUIRED The user has restricted from sending messages OR This action requires a premium account
Expand Down
3 changes: 3 additions & 0 deletions compiler/errors/source/500_INTERNAL_SERVER_ERROR.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
id message
API_CALL_ERROR API call error due to Telegram having internal problems. Please try again later
AUTH_KEY_UNSYNCHRONIZED Internal error, please repeat the method call.
AUTH_RESTART User authorization has restarted
AUTH_RESTART_X Internal error (debug info {value}), please repeat the method call.
CALL_OCCUPY_FAILED The call failed because the user is already making another call
CDN_UPLOAD_TIMEOUT A server-side timeout occurred while reuploading the file to the CDN DC.
CHAT_FROM_CALL_CHANGED
Expand Down Expand Up @@ -45,6 +47,7 @@ SIGN_IN_FAILED Failure while signing in due to Telegram having internal problems
STORAGE_CHECK_FAILED Server storage check failed due to Telegram having internal problems. Please try again later
STORE_INVALID_SCALAR_TYPE Telegram is having internal problems. Please try again later
TIMEOUT A timeout occurred while fetching data from the worker
TRANSLATE_REQ_FAILED Translation failed, please try again later.
UNKNOWN_METHOD The method you tried to call cannot be called on non-CDN DCs
UPLOAD_NO_VOLUME Telegram is having internal problems. Please try again later
VOLUME_LOC_NOT_FOUND Telegram is having internal problems. Please try again later
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]

[tool.hatch.version]
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/methods/chats/get_forum_topics_by_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def get_forum_topics_by_id(
Raises:
ValueError: In case of invalid arguments.
"""
ids, ids_type = (topic_ids, int) if topic_ids else (None, None)
ids, _ids_type = (topic_ids, int) if topic_ids else (None, None)

if ids is None:
raise ValueError("No argument supplied. Either pass topic_ids")
Expand Down
4 changes: 3 additions & 1 deletion pyrogram/raw/core/gzip_packed.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def __init__(self, packed_data: TLObject) -> None:
@staticmethod
def read(data: BytesIO, *args: Any) -> GzipPacked: # noqa: ARG004
# Return the Object itself instead of a GzipPacked wrapping it
return cast(GzipPacked, TLObject.read(BytesIO(decompress(Bytes.read(data)))))
return cast(
"GzipPacked", TLObject.read(BytesIO(decompress(Bytes.read(data))))
)

def write(self, *args: Any) -> bytes: # noqa: ARG002
b = BytesIO()
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/raw/core/primitives/double.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Double(bytes, TLObject):
@classmethod
def read(cls, data: BytesIO, *args: Any) -> float: # noqa: ARG003
return cast(float, unpack("d", data.read(8))[0])
return cast("float", unpack("d", data.read(8))[0])

def __new__(cls, value: float) -> bytes: # type: ignore
return pack("d", value)
4 changes: 3 additions & 1 deletion pyrogram/raw/core/primitives/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
class String(Bytes):
@classmethod
def read(cls, data: BytesIO, *args) -> str: # noqa: ARG003
return cast(bytes, super(String, String).read(data)).decode(errors="replace")
return cast("bytes", super(String, String).read(data)).decode(
errors="replace"
)

def __new__(cls, value: str) -> bytes:
return super().__new__(cls, value.encode())
2 changes: 1 addition & 1 deletion pyrogram/raw/core/primitives/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ def read(cls, data: BytesIO, t: Any = None, *args: Any) -> List: # noqa: ARG003
def __new__(cls, value: list, t: Any = None) -> bytes: # type: ignore
return b"".join(
[Int(cls.ID, False), Int(len(value))]
+ [cast(bytes, t(i)) if t else i.write() for i in value],
+ [cast("bytes", t(i)) if t else i.write() for i in value],
)
2 changes: 1 addition & 1 deletion pyrogram/raw/core/tl_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TLObject:

@classmethod
def read(cls, b: BytesIO, *args: Any) -> Any:
return cast(TLObject, objects[int.from_bytes(b.read(4), "little")]).read(
return cast("TLObject", objects[int.from_bytes(b.read(4), "little")]).read(
b,
*args,
)
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/storage/memory_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def open(self) -> None:
# Telethon format
string = self.session_string[1:]
ip_len = 4 if len(string) == 352 else 16
dc_id, ip, port, auth_key = struct.unpack(
dc_id, _ip, _port, auth_key = struct.unpack(
f">B{ip_len}sH256s",
base64.urlsafe_b64decode(string),
)
Expand Down