Skip to content

fix(hitl): restore form API compatibility and harden IM workflows - #46548

Merged
WTW0313 merged 46 commits into
mainfrom
feat/hitl-im-dev
Nov 17, 2026
Merged

WTW0313 merged 46 commits into
mainfrom
feat/hitl-im-dev

Conversation

@QuantumGhost

@QuantumGhost QuantumGhost commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

AI disclosure: This PR description was primarily drafted with Codex using gpt-6.1-sol. Final human review of the diff and description is pending.

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #46547

Fix Human Input v2 compatibility and reliability across form APIs, workspace channel setup, and IM delivery.

  • Support v2 initiator forms in Dify CLI/OpenAPI, including authorized reads, submissions, file uploads, and resume hints; expose version-specific node schemas and validate v2 authoring configuration.
  • Preserve Service API default metadata, resolved values, paragraph rendering, and response shapes. Expire pending v2 forms when their workflow stops and reject subsequent reads/submissions.
  • Let authenticated workspace members discover credential-free test channels for Debug Mode and message-template testing while retaining administrator-only channel management.
  • Preserve Contact identities during legacy recipient migration, scope directory reads to tenant visibility, and batch initial delivery context reads without holding transactions across provider I/O.
  • Tolerate additive persisted JSON fields and retain unknown delivery-target/locator metadata during updates.
  • Preserve DingTalk/Teams error guidance and provider diagnostics, enforce Slack's total Markdown payload limit, and keep global-timeout stops durable across delayed history saves.
  • Enable HITL IM by default, complete worker queue/configuration examples, and isolate pending channel-guide links. Keep workspace Email management Cloud-only.

Update OpenAPI/generated contracts and regression coverage for the affected APIs, authorization, persistence, and delivery paths.

Validation at 6db7320ba6ad: git diff --check passed. CI is not green: API controller/integration, OpenAPI SDK/Next.js adapter, Python style, and coverage checks have failures. Tests and live deployment scenarios were not rerun for this description update.

Screenshots

Before After
Not captured Not captured

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

From Codex

QuantumGhost and others added 30 commits November 16, 2026 12:06
Resolve existing workspace Contacts by Account identity in a single read-only snapshot. Preserve external one-time email recipients and reject unavailable members without email matching.

Update migration, transport, repository, and runtime regression coverage, together with generated API descriptions.

Specs: dify-specs@3a2e3c8

Assisted-by: Codex:gpt-6.1-sol
(cherry picked from commit 6339e077a3daa2a2f9d2aa6d7cc97dae6282254f)
Verify both providers appear from the available catalog and open their
credential forms for first connections and replacements of an active IM
channel. This protects the behavior reported by WTA-4080, whose development
environment still serves an older mock catalog.

Assisted-by: Codex:gpt-6.1-sol
Read safe Microsoft error codes from the Azure Identity/MSAL exception chain
so nonexistent tenant IDs return invalid_credentials instead of HTTP 500.
Explain the Azure Bot App Tenant ID and Microsoft App ID fields when Teams
rejects the configured tenant. Preserve unclassified execution failures.

Refs: WTA-4091
Assisted-by: Codex:gpt-6.1-sol
Assisted-by: Codex:gpt-6.1-sol
Guide users to check the Corp ID and application credentials when DingTalk
returns 500/unknownError. Preserve the failure status and upstream error facts,
and log safe request identifiers without raw provider messages or credentials.

Add regressions for configuration guidance, unaffected error combinations,
and safe OAuth rejection diagnostics.

Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Preserve Teams tenant feedback alongside actionable DingTalk configuration
guidance. Validate the combined service, controller and provider paths.

Validation: 333 focused tests; Ruff lint/format; Pyrefly checks.
Specs: QuantumGhost/dify-specs@2152629
Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Carry the original upstream request identifier through credential-test failures
and management errors. Preserve numeric DingTalk errcode values instead of SDK
wrapper codes, and keep opaque request IDs unchanged in responses and logs.

Remove the inferred Corp ID guidance. Expected provider rejections remain
business failures without exposing raw provider messages or credentials.

Validation: 345 focused tests; Ruff; Pyrefly; live Console-handler HTTP checks.
Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Expose original DingTalk error codes and opaque request IDs to configuration
callers instead of inferring a Corp ID problem from an ambiguous provider error.

Validation: 345 focused tests; Ruff; Pyrefly; live HTTP response checks.
Specs: QuantumGhost/dify-specs@ce3c5c7
Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Reject Community email channel management before authentication and
provider access, and omit tenant email channels from discovery. Keep
self-hosted delivery on the global mail client and preserve Cloud
workspace Resend configuration.

Refs: WTA-3539
Assisted-by: Codex:gpt-6.1-sol
Apply Slack's 12,000-character limit across all Markdown fragments before
choosing card delivery. Keep representable forms intact and route oversized
forms through the existing approval link delivery.

Cover exact and exceeded limits with the real Slack SDK against local HTTP,
and verify link submission retains its form, recipient and delivery identity.

Refs: WTA-3543
Specs-commit: 4e9aaf7c2ac3dbac48e539794c73fa5a40c79af3
Assisted-by: Codex:gpt-6.1-sol
Expose provider_error_code and provider_request_id on candidate and saved
connection tests and configuration mutation failures. Missing diagnostics
remain null without falling back to Dify request or trace identifiers.

Regenerate API contracts and documentation and cover structured HTTP responses.

Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Assisted-by: Codex:gpt-6.1-sol
Regenerate channel documentation and route summaries from the combined API.

Assisted-by: Codex:gpt-6.1-sol
Expose original provider error codes and request IDs as nullable API fields.
Missing provider identifiers are never generated or replaced by local IDs.

Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Read structured Microsoft OAuth responses through the SDK response hook
instead of searching exception descriptions. Raise the adapter's safe
credential rejection with the upstream error code and optional request ID.

Preserve the exception through the Channel Service and translate it only at
the API boundary, retaining diagnostics on tests and configuration failures.
Never create a provider request ID when Microsoft did not supply one.

Refs: WTA-4091
Assisted-by: Codex:gpt-6.1-sol
Assisted-by: Codex:gpt-6.1-sol

# Conflicts:
#	api/controllers/console/human_input_v2/channel.py
#	api/controllers/console/human_input_v2/errors.py
#	api/openapi/markdown/console-openapi.md
#	api/tests/unit_tests/controllers/console/test_human_input_channel_api.py
#	packages/contracts/generated/api/console/workspaces/types.gen.ts
#	packages/contracts/generated/api/console/workspaces/zod.gen.ts
Read workspace, platform, and external contacts through tenant-scoped
visibility sources while preserving membership precedence and pagination.
Consolidate regression coverage into the existing repository cases.

Validation: 37 repository tests passed; focused Ruff and format checks passed.

Assisted-by: Codex:gpt-6.1-sol
Preserve all provider-supplied string request IDs without regular-expression
or length validation. Escape IDs only when formatting logs, without changing
the diagnostic value returned by the adapter or API.

Cover empty, whitespace, control-character, Unicode and long identifiers.

Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Refs: WTA-4085
Assisted-by: Codex:gpt-6.1-sol
Report the complete Markdown character count and the 12000-character payload limit in assessment diagnostics, including fragments after the first exceeded prefix.

Refs: WTA-3543
Specs-commit: b7abb74
Assisted-by: Codex:gpt-6.1-sol
Align frontend and container defaults, document missing environment settings,
and include the Human Input queues in development and debugger workers.
Move repository database coverage into container E2E tests without external
database URL overrides, and cover default worker queue consumption.

Assisted-by: Codex:gpt-6.1-sol
Move reusable Slack transport and form runtime helpers into tests/helpers and provide fixtures through scoped conftest modules. Preserve existing assessment and delivery coverage.

Assisted-by: Codex:gpt-6.1-sol
Prepare recipient, contact, channel, effective binding, and identity contexts
once per delivery round. Keep provider and credential I/O outside database
transactions and retain a recorded attempt for every actual send.

Cover mixed recipient mapping, current subject visibility, override targets,
and credential transaction boundaries. Use three internal contacts across
both channel scopes to avoid redundant size-based functional coverage.

Validation: 362 focused tests passed; Ruff, formatting, and type checks passed.
Measured context SELECTs fell from 603 to 6 for 100 internal contacts plus
an external contact and a direct email recipient; all 202 attempt inserts
were retained.

Assisted-by: Codex:gpt-6.1-sol
Return version-specific Human Input schemas and standard notification defaults.
Report v2 DSL configuration errors at their field locations. Read and submit
v2 initiator forms through OpenAPI with the existing Account and EndUser
recipient rules, preserving v1 behavior and first-success resume semantics.

Regenerate OpenAPI contracts and cover default templates, caller identity,
form authorization, submission, and compatibility with regression tests.

Assisted-by: Codex:gpt-6.1-sol
Assisted-by: Codex:gpt-6.1-sol
Adjust model extra policies and cover additive reads, target snapshot updates,
and preservation of read-only snapshots and opaque callback payloads.
Keep credential update implementations unchanged.

Refs: WTA-4105
Spec: dify-specs@cea7aebcfee397a9a99b822846b8479be92f2325

Assisted-by: Codex:gpt-6.1-sol
Expire pending v2 forms when their run stops, retain deprecated default selectors, and isolate public response DTOs from frozen persistence values. Preserve legacy paragraph text while keeping resolved defaults explicit across runtime and IM consumers.

Validation: 1633 related unit tests passed; Ruff, format, Pyrefly and OpenSpec checks passed.

OpenSpec-commit: 2627255eda41d005a5f75527f161f20039887687

Assisted-by: Codex:gpt-6.1-sol
Integrate stopped-form invalidation, stable form response projections and resolved-default naming. Update the concurrent OpenAPI fixture to use the renamed internal field.

Validation: 1633 task unit tests passed; integrated suites passed with the OpenAPI fixture adapted.

OpenSpec-commit: 2627255eda41d005a5f75527f161f20039887687

Assisted-by: Codex:gpt-6.1-sol
Assisted-by: Codex:gpt-6.1-sol
@QuantumGhost QuantumGhost changed the title fix(hitl): address IM channel, migration, and timeout regressions fix(hitl): restore form API compatibility and harden IM workflows Nov 17, 2026
@QuantumGhost
QuantumGhost marked this pull request as ready for review November 17, 2026 12:17
Align HITLv2 contract assertions and the Console type baseline with the current implementation. Use a real bearer authenticator in the External SSO test and retain Controller and Integration coverage uploads after test failures.

Validation: 43 focused tests, Ruff, test-double guard, Console type audit, workflow lint, and formatting checks passed.

Assisted-by: Codex:gpt-6.1-sol
Add the missing batch Account lookup method to the Contact capability test port. Keep unexpected identity reads rejected and preserve the existing service scenarios.

Validation: make type-check-core, three focused tests, and Ruff checks passed.

Assisted-by: Codex:gpt-6.1-sol
Wait for password-save requests to reach the network boundary before asserting their exact count. Preserve the focus and retry checks, and upload available browser coverage even when a test fails.

Validation: focused Chromium spec, scoped vp check, workflow lint, and formatting checks passed.

Assisted-by: Codex:gpt-6.1-sol
WTW0313
WTW0313 previously approved these changes Nov 17, 2026
@WTW0313
WTW0313 enabled auto-merge November 17, 2026 13:24
@WTW0313
WTW0313 added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 7b19f9d Nov 17, 2026
116 of 118 checks passed
@WTW0313
WTW0313 deleted the feat/hitl-im-dev branch November 17, 2026 14:02
@hyoban hyoban mentioned this pull request Nov 17, 2026
3 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Human Input v2 form compatibility, channel access, and delivery regressions

2 participants