jackwener/OpenCLI · error · CommandExecutionError
Nowcoder detail returned a different post identity
Error message
Nowcoder detail returned a different post identity
What it means
After projecting the detail, projectNowcoderDetail verifies that the returned post's identity matches what you asked for: for content targets the API's id must equal the requested content ID; for moment targets the API's uuid must equal the requested UUID. If Nowcoder's API returns data for a different post than requested (redirect, stale cache, alias resolution), the library throws this CommandExecutionError instead of showing wrong data.
Source
Thrown at clis/nowcoder/posts.js:209
|| (host !== 'nowcoder.com' && host !== 'www.nowcoder.com')) {
throw new ArgumentError('nowcoder detail only accepts canonical https://www.nowcoder.com post URLs');
}
const content = url.pathname.match(/^\/discuss\/([1-9]\d*)\/?$/);
if (content) return { post_type: 'content', value: content[1] };
const moment = url.pathname.match(/^\/feed\/main\/detail\/([0-9a-f]{32})\/?$/i);
if (moment) return { post_type: 'moment', value: moment[1].toLowerCase() };
throw new ArgumentError('Unsupported Nowcoder URL; expected /discuss/<content-id> or /feed/main/detail/<moment-uuid>');
}
export function projectNowcoderDetail(data, target) {
if (!isRecord(data) || !isRecord(data.frequencyData)) throw new CommandExecutionError('Nowcoder detail returned malformed post data');
const isContent = target.post_type === 'content';
const expectedEntityType = isContent ? CONTENT_ENTITY_TYPE : MOMENT_TYPE;
if (data.entityType !== expectedEntityType) throw new CommandExecutionError('Nowcoder detail returned a mismatched post entity type');
const uuid = requiredUuid(data.uuid, `${target.post_type} uuid`);
const entityId = requiredId(data.entityId, `${target.post_type} entity id`);
const id = isContent ? requiredId(data.id, 'content id') : uuid;
if (isContent ? id !== target.value : uuid !== target.value) throw new CommandExecutionError('Nowcoder detail returned a different post identity');
if (!isContent && entityId !== requiredId(data.id, 'moment id')) throw new CommandExecutionError('Nowcoder detail returned mismatched moment entity ids');
const expectedAuthorId = isContent ? data.authorId : data.userId;
const body = cleanBody(isContent ? data.richText : data.content, `${target.post_type} detail body`);
return {
post_type: target.post_type,
id,
uuid,
entity_id: entityId,
url: isContent
? `https://www.nowcoder.com/discuss/${id}`
: `https://www.nowcoder.com/feed/main/detail/${uuid}`,
title: optionalText(data.title, `${target.post_type} title`) || '(untitled)',
...authorFields(data.userBrief, expectedAuthorId, target.post_type),
content: body,
likes: metric(data.frequencyData, 'likeCnt'),
comments: metric(data.frequencyData, 'commentCnt'),
views: metric(data.frequencyData, 'viewCnt'),
time: isoTime(isContent ? data.createTime : data.createdAt, `${target.post_type} timestamp`),View on GitHub (pinned to 49907e53dc)
Solutions
- Re-check the content ID / moment UUID for typos and confirm it matches the post you want in the browser.
- Clear any cache/CDN layer between you and the API, or retry to rule out stale responses.
- If the post was deleted or merged, find and use the new canonical ID/UUID.
- If this occurs consistently for a valid ID, report it — the identity check may need to accommodate server-side ID migration.
Example fix
// before nowcoder detail 70123457 // typo'd id resolves to another post's record // after nowcoder detail 70123456 // id copied from the post's canonical URL
Defensive patterns
Strategy: validation
Validate before calling
// verify the canonical URL actually resolves to this exact ID before fetching
const canonical = `https://www.nowcoder.com/discuss/${id}`;
// confirm canonical URL matches the post you intend before invoking the CLI Try / catch
try {
const post = await nowcoderDetail(id);
} catch (err) {
if (err instanceof CommandExecutionError && /different post identity/.test(err.message)) {
console.error(`API returned a different post for ${id}; it may be deleted/merged. Re-fetch the canonical URL.`);
} else throw err;
} Prevention
- Copy IDs from the canonical post URL, not from search results or caches.
- Watch for deleted/merged posts — identity mismatches usually mean the ID no longer resolves to itself.
- Retry once on failure; persistent mismatches indicate the ID is stale.
When it happens
Trigger: Requesting /discuss/<id> but the API returns a record whose id differs from <id> (e.g. the ID was redirected/merged to another post), or requesting a moment UUID that the API resolves to a different uuid in the response.
Common situations: Deleted posts being aliased to other content; cached/stale CDN responses; typos in the ID that happen to resolve to another valid post; Nowcoder server-side redirects on merged or moderated posts.
Related errors
- Nowcoder detail returned mismatched moment entity ids
- Malformed toutiao recommend row: group_id/source_url mismatc
- Bilibili ${label} API returned a malformed payload
- Bilibili ${label} API failed: ${message} (${payload.code})
- Bilibili ${label} API returned malformed data
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0b5177779df04433.
Report an issue: GitHub.