Commit Graph

36 Commits

Author SHA1 Message Date
gigglewang0417 b8ab27c5ee test(cli/e2e): add member management E2E suite (get/create/delete/set member)
28 tests covering all four member commands:

get member (10 tests)
  - list contains created member
  - required column headers (ID/NAME/EMAIL/ROLE/STATUS)
  - authenticated account appears as owner/active
  - JSON shape: data array with id/email/role/status fields
  - no ANSI codes in non-TTY output
  - pipe-friendly JSON output (ends with newline)
  - -o yaml returns valid YAML
  - -w flag overrides workspace
  - unauthenticated → exit 4

set member (7 tests)
  - promote normal → admin, verify via get member
  - demote admin → normal, verify via get member
  - --role owner rejected client-side (exit 2)
  - missing --role → usage error
  - missing member-id → usage error
  - non-existent UUID → server error
  - unauthenticated → exit 4

create member error paths (5 tests)
  - invalid role (superadmin) rejected client-side (exit 2)
  - --role owner rejected client-side (exit 2)
  - missing --email → usage error
  - missing --role → usage error
  - unauthenticated → exit 4

delete member (6 tests)
  - success: member removed from list
  - cannot delete self → server error
  - missing member-id → usage error
  - non-existent UUID → server error
  - -o json on error → structured error envelope
  - unauthenticated → exit 4

Data lifecycle: beforeAll invites two auto_test+<ts>@dify.ai
members; afterAll cleans them up. No extra env vars required.
2026-06-18 17:39:11 +08:00
gigglewang0417 fadf3acc94 test(cli/e2e): remove 5.70f — test premise was incorrect
5.70f assumed that passing wrong-type inputs to run app would be
intercepted by @accepts(body=) and return HTTP 422 with canonical
ErrorBody details[]. This premise is wrong:

- @accepts(body=) validates the API schema (inputs must be a dict),
  not the workflow-level variable types (num must be a number)
- Wrong-type workflow inputs go through the SSE execution layer,
  returning an error event with status:500, not a canonical 422
- The CLI receives this via decodeStreamError, not classifyResponse,
  so rawResponse is never set and error.server is never populated

The behavior tested by 5.70f (CLI rendering details[] as indented
lines) remains valid as a contract requirement but has no triggerable
E2E path on the current server. Covered by unit tests for renderHuman.
2026-06-17 11:59:56 +08:00
gigglewang0417 2da773e8d8 test(cli/e2e): rewrite 5.70d-h — correct triggers and add V2 hint priority test
Rewrites 5 existing tests and adds 1 new test to align with the V2 ErrorBody spec
(history page: https://km.dify.langgenius.ai/wiki/spaces/Enterprise/history/490602534/):

Trigger fix (5.70d, 5.70g, 5.70h):
  Before: 'run app wrong-type input' → hits SSE execution layer → HTTP 500
  After:  'describe app ZERO' → hits @returns canonical 404 ErrorBody → error.server set
  Result: 5.70d, 5.70g, 5.70h now pass on the current server

Trigger fix (5.70e):
  Before: 'run app wrong-type input' → SSE 500, no details
  After:  direct fetch to GET /apps?page=not-integer → @accepts(query=) returns 422
          with canonical ErrorBody and details[] (bypasses CLI client-side page validation)
  Result: 5.70e now passes on the current server

Forward-looking (5.70f):
  Kept 'run app wrong-type input' trigger — documents that once @accepts covers the
  app run path, details lines will appear; remains red until that server change deploys

New (5.70g2):
  Tests V2 spec correction: hint priority is cliHint ?? server?.hint (CLI wins).
  V1 doc incorrectly said 'server wins'; V2 aligned with codebase.
  Trigger: unauthenticated → 401 AuthExpired → CLI AUTH_LOGIN_HINT appears at
  error.hint regardless of any server-provided hint. Passes on current server.
2026-06-17 10:42:37 +08:00
gigglewang0417 e3e7ff26a5 test(cli/e2e): add 5.70i/5.70j — 404 canonical body and RFC 8628 boundary
5.70i [P1] — /openapi/v1 unknown route 404 carries canonical ErrorBody
             (code, status) and must NOT contain flask-restx route suggestions
             ('did you mean'); pins the ExternalApi._help_on_404 fix from
             PR #37285

5.70j [P1] — device-flow token endpoint returns RFC 8628 {error: string}
             on failure, not the canonical ErrorBody shape; pins the
             explicit RFC 8628 exception documented in PR #37285 and
             confirms zErrorBody.safeParse would fail gracefully on this
             shape (serverError = undefined, generic message, no crash)
2026-06-16 18:09:19 +08:00
gigglewang0417 1bd9cf8cc6 test(cli/e2e): add ErrorBody contract tests for error.server structure
Add 5 new test cases (5.70d-h) that verify the CLI correctly forwards the
canonical ErrorBody from the server when request validation fails (422).

These tests define the E2E contract introduced by the OpenAPI ErrorBody
unification spec. They will be red until the server-side change deploys;
the spec document is at:
  https://km.dify.langgenius.ai/wiki/spaces/Enterprise/pages/490602534/

5.70d [P0] — JSON envelope contains error.server with code='invalid_param',
             status=422, and a non-empty message string
5.70e [P1] — error.server.details array carries field-level error entries
             with the {type, loc, msg} shape from ErrorDetail
5.70f [P1] — human-readable text mode renders each details entry as
             '  - <loc>: <msg> (<type>)' line (no -v required)
5.70g [P1] — text mode header code is server's 'invalid_param', not CLI's
             'server_4xx_other' (server code wins in renderHuman)
5.70h [P1] — JSON envelope error.code is CLI classification code
             ('server_4xx_other'); semantic code is in error.server.code
2026-06-16 17:19:19 +08:00
gigglewang 56a026505e fix(cli/e2e): remove LLM nodes from fixture DSLs and fix test assertions (#37463)
Co-authored-by: yunlu.wen <yunlu.wen@dify.ai>
2026-06-16 08:58:53 +00:00
Xiyuan Chen a18635e566 feat(cli): difyctl per-commit edge distribution via Cloudflare R2 (#37454) 2026-06-15 09:30:35 +00:00
Yunlu Wen d315ae3b80 fix: change store apis to async (#37329) 2026-06-15 02:24:51 +00:00
Stephen Zhou e0c6ca9930 fix: GET query parameter OpenAPI contracts (#37378)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-12 09:01:22 +00:00
Asuka Minato 6c0cce4b7f chore: update to openapi v3 by change dep (#37316)
Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Co-authored-by: Stephen Zhou <hi@hyoban.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-12 07:52:19 +00:00
L1nSn0w 07eb4903b8 feat: 429 rate-limit handling on the unified ErrorBody contract (openapi + difyctl) (#37313)
Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
2026-06-12 06:35:15 +00:00
Xiyuan Chen a650ffc00a refactor(cli): auth/workspace cleanup — record-backed token store (#37219)
Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai>
2026-06-12 03:10:54 +00:00
Xiyuan Chen ba59d9a4ac feat: unified ErrorBody contract for /openapi/v1 and difyctl (#37285)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-11 10:26:27 +00:00
Yunlu Wen 0a051b598f feat: support import / export dsl in CLI (#37232)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: cheatofrom <85830867+cheatofrom@users.noreply.github.com>
Co-authored-by: Escape0707 <tothesong@gmail.com>
Co-authored-by: Rohit Gahlawat <personal.rg56@gmail.com>
Co-authored-by: L1nSn0w <l1nsn0w@qq.com>
Co-authored-by: 盐粒 Yanli <yanli@dify.ai>
2026-06-10 09:51:40 +00:00
gigglewang 534dd50d14 fix(e2e): replace non-UUID workspace IDs in auth/use.e2e.ts and global-flags.e2e.ts (#37266) 2026-06-10 09:14:19 +00:00
Yunlu Wen 19d2a4d7a0 fix: run ci properly on pr (#37233) 2026-06-09 10:06:55 +00:00
gigglewang 0019e6a6f3 test(cli-e2e): full E2E test suite for difyctl — auth / run / discovery / framework / output / error-handling / agent (#36874)
Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai>
2026-06-09 07:50:05 +00:00
Xiyuan Chen 1502a57381 feat(api,cli): strict UUID validation for app-id and workspace-id (#37212)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-09 07:35:18 +00:00
L1nSn0w a15ecf6bec feat(cli): adopt generated oRPC contract for unary endpoints (#37090)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-08 08:09:44 +00:00
Xiyuan Chen 759b4cbad3 feat(cli): difyctl release pipeline + tokenless installers (#37036) 2026-06-07 23:30:29 +00:00
Xiyuan Chen e40b30d746 fix(difyctl): improve auth login host prompt UX (#37054) 2026-06-05 07:57:29 +00:00
L1nSn0w f0fd7ddb60 feat(cli): unified help system (#36896)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 07:27:28 +00:00
Yunlu Wen f19679b217 refactor: improve network error and allow verbose output (#36923) 2026-06-02 10:43:40 +00:00
Xiyuan Chen 6ce61eae59 fix(cli): invalidate app metadata cache on 422 to clear stale data (#36921) 2026-06-02 05:20:33 +00:00
Xiyuan Chen 0da13dfe4d refactor(cli): unify token storage behind Store + add host/account switching (#36830) 2026-06-02 04:05:53 +00:00
L1nSn0w cfc1cf2b8c refactor(cli/http): replace ky with a self-contained HTTP client (#36711)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-01 09:04:42 +00:00
yyh a8a2ca7b98 chore(cli): move eslint config into cli package (#36878) 2026-06-01 03:54:14 +00:00
Yunlu Wen c0ee821d45 refactor: use absolute path for inter dir importing (#36822)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-01 01:32:16 +00:00
Yunlu Wen b6f92f1dc4 fix(cli): fix style (#36821) 2026-05-29 08:34:36 +00:00
Yunlu Wen 5070cc9668 refactor(cli): optimize error handling in flag parsing (#36810) 2026-05-29 07:39:26 +00:00
Xiyuan Chen 30270b5c30 fix(device): surface SSO errors on /device and fix CLI null-account crash on external-SSO login (#36781) 2026-05-29 06:51:34 +00:00
zyssyz123 2cc567c6a3 feat: add DTO for agent api (#36797)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-29 03:36:41 +00:00
Yunlu Wen 3596d12e4c refactor(cli): use Store interface as token storage (#36726) 2026-05-28 10:02:51 +00:00
Yunlu Wen a8d380bcaf refactor(cli): add kvstore and platform interface (#36687) 2026-05-27 05:30:12 +00:00
L1nSn0w 6e1e0d9439 feat(openapi,cli): workspace switch + member management (#36651)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-27 03:05:47 +00:00
Yunlu Wen a728e0ac69 feat: adding dify cli (#36348)
Co-authored-by: GareArc <garethcxy@dify.ai>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: L1nSn0w <l1nsn0w@qq.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: gigglewang <gigglewang@dify.ai>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
2026-05-26 01:12:36 +00:00