refactor(api): type _sign_query return with SignedQueryDict TypedDict#34981
Open
aviu16 wants to merge 1 commit intolanggenius:mainfrom
Open
refactor(api): type _sign_query return with SignedQueryDict TypedDict#34981aviu16 wants to merge 1 commit intolanggenius:mainfrom
aviu16 wants to merge 1 commit intolanggenius:mainfrom
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-12 03:36:44.561506228 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-12 03:36:36.871330018 +0000
@@ -20,6 +20,8 @@
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:321:29
ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:388:27
+ERROR TypedDict `SignedQueryDict` does not have key `as_attachment` [bad-typed-dict-key]
+ --> core/app/workflow/file_runtime.py:107:19
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
--> core/llm_generator/llm_generator.py:85:60
ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, float | int], stream=Literal[False]) [no-matching-overload]
|
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a SignedQueryDict TypedDict to make _sign_query’s fixed query-parameter shape explicit and updates _sign_query’s return annotation accordingly.
Changes:
- Add
SignedQueryDictTypedDict(timestamp,nonce,sign) - Update
_sign_queryreturn type fromdict[str, str]toSignedQueryDict
Comments suppressed due to low confidence (1)
api/core/app/workflow/file_runtime.py:143
- Changing
_sign_queryto return a totalSignedQueryDictmakesresolve_upload_file_url()'squery["as_attachment"] = "true"assignment a type error becauseas_attachmentis not a declared key on the TypedDict. Either (a) includeas_attachment: NotRequired[str]on the query TypedDict used byresolve_upload_file_url, or (b) keep_sign_queryreturningSignedQueryDictbut copy/widen before mutation (e.g., cast/dict()/{**...}todict[str, str]) so adding extra query params is type-safe.
def _sign_query(self, *, payload: str) -> SignedQueryDict:
timestamp = str(int(time.time()))
nonce = os.urandom(16).hex()
sign = hmac.new(self._secret_key(), f"{payload}|{timestamp}|{nonce}".encode(), hashlib.sha256).digest()
return {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #32863 (
api/core/app/workflow/file_runtime.py)Summary
SignedQueryDictTypedDict for the_sign_queryreturn typedict[str, str]return annotation with the new TypedDictWhy this change
_sign_queryreturns a fixed 3-key dict (timestamp,nonce,sign) used as URL query params for signed file access. The baredict[str, str]hides this structure from callers and downstream urllib.parse.urlencode usage.Changes
api/core/app/workflow/file_runtime.py: DefineSignedQueryDict, annotate_sign_queryreturn type