Skip to content

Fix CAPEX shortcut silently pointing at the wrong column#34

Open
atalha1 wants to merge 1 commit into
SimFin:masterfrom
atalha1:fix-capex-shortcut-collision
Open

Fix CAPEX shortcut silently pointing at the wrong column#34
atalha1 wants to merge 1 commit into
SimFin:masterfrom
atalha1:fix-capex-shortcut-collision

Conversation

@atalha1

@atalha1 atalha1 commented Jul 19, 2026

Copy link
Copy Markdown

Fixes #10.

names.py currently has:

CAPEX = 'Capital Expenditures'
...
CAPEX = CHG_FIX_ASSETS_INT = 'Change in Fixed Assets & Intangibles'

Since the file is generated in alphabetical order by column name, the second line runs after the first and CAPEX ends up meaning 'Change in Fixed Assets & Intangibles' instead of 'Capital Expenditures'. No error, no warning, just wrong data for anyone using sf.CAPEX.

Root cause is in tools/generate_names.py. It dedupes shortcuts within a single column-name, but never checks whether the same shortcut got attached to two different names on the server side. Added that check: if a shortcut is claimed by more than one name, it's dropped from both (with a stderr warning listing which names collided) instead of letting whichever comes later alphabetically silently win.

I skip and warn instead of guessing which name should keep the shortcut, since I don't have a way to check which literal string actually shows up in the real CSV column headers for that case, and getting it wrong would be worse than leaving it undefined.

Also patched the specific CAPEX line in the shipped names.py directly, since that file won't get regenerated until someone reruns the tool against live data.

Tested the generator fix locally against a fake JSON payload reproducing the CAPEX collision (monkeypatched requests.get, no live server needed) and confirmed: the colliding shortcut gets dropped from both names with a warning, non-conflicting entries are written unchanged, and the multi-shortcut case (e.g. REVENUE = SALES = ...) still works normally.

CAPEX was getting silently redefined. names.py has:

  CAPEX = 'Capital Expenditures'
  ...
  CAPEX = CHG_FIX_ASSETS_INT = 'Change in Fixed Assets & Intangibles'

since the file is written in alphabetical order by column name, the
second line runs later and CAPEX ends up meaning 'Change in Fixed
Assets & Intangibles' instead of 'Capital Expenditures', with no
error, just wrong data for anyone using sf.CAPEX.

root cause is in tools/generate_names.py: it dedupes shortcuts within
a single column-name but never checks whether the same shortcut is
attached to two different names on the server side. added that check,
if a shortcut is claimed by more than one name it gets skipped for
both (with a clear stderr warning) instead of one silently winning.
figured skipping and warning is safer than guessing which name should
keep it since I can't verify that against real data.

also manually fixed the specific CAPEX line in the currently shipped
names.py, since that part doesn't get regenerated until someone reruns
the tool against the live server.

fixes SimFin#10
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.

Bug Report

1 participant