Skip to content

fix(twitter): repair search and tweets readback#1512

Merged
jackwener merged 2 commits into
jackwener:mainfrom
darthjaja6:fix-twitter-readback
May 13, 2026
Merged

fix(twitter): repair search and tweets readback#1512
jackwener merged 2 commits into
jackwener:mainfrom
darthjaja6:fix-twitter-readback

Conversation

@darthjaja6
Copy link
Copy Markdown
Contributor

Summary\n- switch twitter/search to the current SearchTimeline POST GraphQL path instead of brittle SPA navigation\n- resolve current X operation metadata from loaded client bundles and normalize Browser Bridge GraphQL payload envelopes\n- repair twitter/tweets parsing for current UserTweets payloads and add post id/url readback columns\n\n## Verification\n- npx vitest run --project adapter clis/twitter/search.test.js clis/twitter/tweets.test.js clis/twitter/post.test.js clis/twitter/shared.test.js\n- npm run typecheck\n- npm run build\n- npm run check:silent-column-drop\n- live: node dist/src/main.js --profile 86v9bx9k twitter search "VibeShare agent publishing" --limit 1 -f json --trace retain-on-failure\n- live: node dist/src/main.js --profile 86v9bx9k twitter tweets darthjajaj6z --limit 1 -f json --trace retain-on-failure

@darthjaja6 darthjaja6 force-pushed the fix-twitter-readback branch from 3b1b0e3 to a751a0c Compare May 12, 2026 20:16
…ns empty

The bundle parser in resolveTwitterOperationMetadata locates the queryId via
`queryId:"..."` inside a ~2500-char snippet around the operationName marker,
then independently extracts `featureSwitches:[...]` and `fieldToggles:[...]`
via separate regexes. When minification rearranges the snippet (or the
snippet window truncates before the array), either regex can miss while
queryId still resolves; keysToFlags(undefined) then returns {}.

sanitizeTwitterOperationMetadata previously accepted any object as
features / fieldToggles, including {}. Twitter's GraphQL endpoint rejects
SearchTimeline / UserTweets requests with empty features (HTTP 400),
surfacing a misleading "queryId may have expired" error — the queryId is
fresh; only the feature flags are missing.

Guard against this by deferring to the baked fallback whenever the resolved
map is empty. Adds a JSDOM-free unit test that, reverse-validated, fails on
the un-fixed code with the exact silent-fallback shape.

Refs PR jackwener#1512
@jackwener
Copy link
Copy Markdown
Owner

Maintainer-edit 05f26048 — fix a silent-fallback bug in sanitizeTwitterOperationMetadata.

The bug

resolveTwitterOperationMetadata's bundle parser locates queryId:"..." and then independently extracts featureSwitches:[...] / fieldToggles:[...] via separate regexes. When minification rearranges the snippet (or the 2500-char snippet window truncates before the array), either regex can miss while queryId still resolves. keysToFlags(undefined) then returns {}.

sanitizeTwitterOperationMetadata previously accepted any object as features / fieldToggles, including {}. Twitter's GraphQL endpoint rejects SearchTimeline / UserTweets requests with empty features (HTTP 400), surfacing the misleading "queryId may have expired" error — the queryId is actually fresh; only the feature flags are missing.

The fix

Defer to the baked fallback whenever the resolved map is empty:

features: value?.features
    && typeof value.features === 'object'
    && Object.keys(value.features).length > 0
    ? value.features
    : normalizedFallback.features,

Reverse-validation

I stashed the production change and ran just the new test against unfixed code:

- "features": { "fallback_feature": true },
+ "features": {},

Confirms the test would have caught the bug.

Tests + audits

  • clis/twitter/shared.test.js: 20 → 22 (+ 2 new — empty-map fallback + null fallback)
  • Full twitter suite: 222/222
  • check-silent-column-drop.mjs: 103/103 (0 new)
  • check-typed-error-lint.mjs: 189/189 (0 new)

@jackwener jackwener merged commit 67599ea into jackwener:main May 13, 2026
11 checks passed
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.

2 participants