Skip to content

refactor: improve network error and allow verbose output#36923

Merged
GareArc merged 19 commits into
langgenius:mainfrom
wylswz:fix/cli-network-err
Jun 2, 2026
Merged

refactor: improve network error and allow verbose output#36923
GareArc merged 19 commits into
langgenius:mainfrom
wylswz:fix/cli-network-err

Conversation

@wylswz
Copy link
Copy Markdown
Contributor

@wylswz wylswz commented Jun 2, 2026

Important

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

Summary

  • removed unreliable network error handling
  • provided a global -v flag to allow verbose output
  • moved http related properties from BaseError to HttpClientError

Screenshots

Before After
... ...

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 added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@wylswz wylswz requested a review from a team as a code owner June 2, 2026 04:10
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. javascript refactor labels Jun 2, 2026
@wylswz wylswz force-pushed the fix/cli-network-err branch from bed0a02 to 7cbd650 Compare June 2, 2026 04:50
@wylswz wylswz requested review from GareArc and lin-snow June 2, 2026 06:52
Comment thread cli/src/http/client.ts
Comment thread cli/src/errors/base.ts
Comment thread cli/src/framework/flags.ts
Comment thread cli/src/http/error-mapper.ts Outdated
Comment thread cli/src/errors/base.ts
@wylswz wylswz requested a review from lin-snow June 2, 2026 07:59
@lin-snow
Copy link
Copy Markdown
Contributor

lin-snow commented Jun 2, 2026

@wylswz

Thanks — redact message (ea3371e) looks correct, and rendering the body under verbose (1ef9b6b) gives -v a real effect now. A few leftovers:

  1. Dead init.verbose still there. client.ts:137,141 still sets init.verbose = true on undici fetch, which ignores it. Now that verbose works via
    humanError()/isVerbose(), this line (and the verbose?: boolean type) is pure no-op — please remove it to avoid implying fetch-level verbosity.
  2. raw_response is printed unredacted. errors/base.ts:134 pushes this.rawResponse directly — inconsistent with the redaction you just added. Suggest
    redactBearer(this.rawResponse).
  3. Scope check. rawResponse is only set on 4xx/5xx (error-mapper.ts), not on 401 or transport errors, and toEnvelope() doesn't include it — so -v
    shows nothing for those paths or --format json. Fine as an MVP, just confirming it's intended.
  4. (nit) trailing whitespace on errors/base.ts:127.

@wylswz
Copy link
Copy Markdown
Contributor Author

wylswz commented Jun 2, 2026

@wylswz

Thanks — redact message (ea3371e) looks correct, and rendering the body under verbose (1ef9b6b) gives -v a real effect now. A few leftovers:

  1. Dead init.verbose still there. client.ts:137,141 still sets init.verbose = true on undici fetch, which ignores it. Now that verbose works via
    humanError()/isVerbose(), this line (and the verbose?: boolean type) is pure no-op — please remove it to avoid implying fetch-level verbosity.
  2. raw_response is printed unredacted. errors/base.ts:134 pushes this.rawResponse directly — inconsistent with the redaction you just added. Suggest
    redactBearer(this.rawResponse).
  3. Scope check. rawResponse is only set on 4xx/5xx (error-mapper.ts), not on 401 or transport errors, and toEnvelope() doesn't include it — so -v
    shows nothing for those paths or --format json. Fine as an MVP, just confirming it's intended.
  4. (nit) trailing whitespace on errors/base.ts:127.
  1. It's a false positive.

Comment thread cli/src/errors/base.ts Outdated
Copy link
Copy Markdown
Contributor

@GareArc GareArc left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 2, 2026
@GareArc GareArc added this pull request to the merge queue Jun 2, 2026
Merged via the queue into langgenius:main with commit f19679b Jun 2, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants