Skip to content

fix(barchart): add CSRF retry and mostActive fallback to flow#51

Merged
jackwener merged 1 commit intojackwener:mainfrom
himself65:fix/barchart-flow-csrf
Mar 18, 2026
Merged

fix(barchart): add CSRF retry and mostActive fallback to flow#51
jackwener merged 1 commit intojackwener:mainfrom
himself65:fix/barchart-flow-csrf

Conversation

@himself65
Copy link
Contributor

Summary

Fixes opencli barchart flow returning no data by addressing two root causes:

  • CSRF token timing: Angular may not have injected the <meta name="csrf-token"> tag when the evaluate runs. Added a polling loop (up to 5s) to wait for it, with a clear error message if it never appears.
  • Empty unusual_activity list: The options.unusual_activity.stocks.us list is empty outside market hours. Added options.mostActive.us as a fallback which always has data.
  • Removed dead DOM fallback: The <tr> DOM parser never matched anything because barchart uses Angular components, not standard table elements.

Test plan

  • npm run build passes
  • opencli barchart flow --limit 5 returns data (via mostActive fallback after hours)
  • opencli barchart flow --type call --limit 5 correctly filters to calls only
  • opencli barchart flow --type put --limit 5 correctly filters to puts only

The flow command returned no data because:
1. The CSRF token may not be in the DOM yet when Angular is still
   initializing — add a polling loop (up to 5s) to wait for it
2. The unusual_activity list is empty outside market hours — fall back
   to the mostActive list which always has data
3. Remove the DOM table fallback that never matched (barchart uses
   Angular components, not standard <tr> elements)
@jackwener jackwener merged commit 2d52abd into jackwener:main Mar 18, 2026
6 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