Skip to content

portal toc new: unauthenticated run writes a stub toc.yml with exit 0, then hangs #301

Description

@MuhammadRafay1

Summary

apimatic portal toc new handles a failed TOC extraction badly in two independent
ways. Reproduce with apimatic auth logout then
apimatic portal toc new --input <dir-with-src/spec> --force:

▲ Falling back to the default TOC structure.
● The TOC file successfully created at: …\src\content\toc.yml
└ Succeeded
<hangs — never exits>

1. The 401 is swallowed. actions/portal/toc/new-toc.ts:86-89 treats every
generateTocData error as benign: it overwrites the existing toc.yml with one
containing no endpoint/model/webhook components and returns
ActionResult.success() (exit 0). The user is never told to log in, and CI sees
success. portal-service.ts:333 already produces the right message — the action
discards it.

2. The process then hangs indefinitely. generateTocData is a
stream-response endpoint, so on error the SDK returns ApiError.body as an
undrained IncomingMessage. The TLS socket stays open, and since outro() only
sets process.exitCode (prompts/format.ts:48) with no process.exit anywhere,
Node waits forever. Confirmed by handle probe (TLSSocket … readable=true);
destroying that stream turns a 90s hang into a 3s exit 0. Not specific to this
command or to being logged out
— latent in any stream-endpoint error, including
the portal and SDK download calls.

Expected

An actionable auth message, a non-zero exit, the existing toc.yml left
untouched, and the process exiting.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions