Skip to content

fix(zsxq): accept topic_id as string in getTopicFromResponse#963

Merged
jackwener merged 2 commits intojackwener:mainfrom
fgksgf:fix/zsxq-topic-id-type
Apr 11, 2026
Merged

fix(zsxq): accept topic_id as string in getTopicFromResponse#963
jackwener merged 2 commits intojackwener:mainfrom
fgksgf:fix/zsxq-topic-id-type

Conversation

@fgksgf
Copy link
Copy Markdown
Contributor

@fgksgf fgksgf commented Apr 11, 2026

Bug

opencli zsxq topic <id> returns "⚠️" (NOT_FOUND) for all valid topic IDs because the ZSXQ API returns topic_id as a string, but getTopicFromResponse() only checked for typeof === 'number'.

Fix

Extend the type guard in getTopicFromResponse() to also accept strings:

- if (typeof data.topic_id === 'number')
+ if (typeof data.topic_id === 'number' || typeof data.topic_id === 'string')

This allows the function to correctly recognize topics when the API returns topic_id as a string (e.g., "22255514214444820").

Testing

Confirmed the bug exists in v1.7.0. Fix compiled and tested locally against the actual API response structure.

The ZSXQ API returns topic_id as a string, but getTopicFromResponse()
only checked for typeof === 'number', causing it to fall through and
return null. This made 'opencli zsxq topic <id>' fail with NOT_FOUND
for all valid topic IDs.
@Astro-Han
Copy link
Copy Markdown
Contributor

This looks good to me. The change is small, the bug report matches the diff, and I did not spot a regression risk from this patch.

…/{id}

The ZSXQ API requires topics to be fetched within their group context.
Change /v2/topics/{id} -> /v2/groups/{groupId}/topics/{id} for both
the detail and comments endpoints. Also adds optional --group_id arg.
@jackwener jackwener merged commit 1ffe12f into jackwener:main Apr 11, 2026
jackwener added a commit that referenced this pull request Apr 11, 2026
The test mock was missing the evaluate call for getActiveGroupId,
which was added when #963 introduced the group_id parameter.
jackwener added a commit that referenced this pull request Apr 11, 2026
The test mock was missing the evaluate call for getActiveGroupId,
which was added when #963 introduced the group_id parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants