dify/api/core/app
Taranum01 3cfd24557f fix(api): grant EndUser access to file-list input defaults
Fixes #40411

Workflows that set a default value on a File List (or single File) input
break under WebApp runs: the form defaults are uploaded by the studio
account, but WebApp runs execute as EndUser, and the file access
controller filters out files the EndUser does not own. The result is
`ValueError("Invalid upload file")` raised from
`factories.file_factory.builders._build_from_local_file` before the
workflow can read the default value. Preview works fine because Account
runs bypass the ownership filter.

The grant mechanism (added in #36175) already allows the runtime to
allowlist specific upload file IDs during execution. The same grant
fits here: input default files are studio-uploaded, but they are
trusted by the form author, so the active execution scope should be
allowed to read them.

Changes:
1. Extract upload_file_id / reference / related_id from FILE and
   FILE_LIST input mappings before `build_from_mapping` runs.
2. Add the IDs to the active file access scope via
   `grant_upload_file_access` so the access controller treats them
   as already-vetted for the current EndUser.
3. Regression test exercising the EndUser path with three file IDs
   (single FILE + FILE_LIST default) and asserting the scope grants
   the correct set.

This is the same class of bug as #36175/#36195 for retrieval
attachments, but for the input-default path.
2026-08-15 03:01:28 +05:30
..
app_config refactor: explicit DB session propagation across backend paths (#38559) 2026-07-15 06:48:28 +00:00
apps fix(api): grant EndUser access to file-list input defaults 2026-08-15 03:01:28 +05:30
entities fix(agent): meter internal LLM calls through API (#40613) 2026-08-13 12:15:44 +00:00
features refactor: explicit DB session propagation across backend paths (#38559) 2026-07-15 06:48:28 +00:00
file_access refactor: add missing @override decorator to file access controller and workflow file runtime (#36495) 2026-05-21 19:39:51 +00:00
layers fix: preserve ResponseStreamFilter state across workflow pause/resume (#38540) 2026-07-09 01:05:47 +00:00
llm fix(agent): meter internal LLM calls through API (#40613) 2026-08-13 12:15:44 +00:00
task_pipeline chore(api): remove unreachable match suppressions (#39949) 2026-08-04 11:56:37 +00:00
workflow fix: meter hosted LLM invocations (#40589) 2026-08-12 12:33:21 +00:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00