Skip to content

fix: export the tombola level for octoberfest bribes - #68

Merged
timzatko merged 1 commit into
mainfrom
fix/tombola-level
Sep 10, 2026
Merged

timzatko merged 1 commit into
mainfrom
fix/tombola-level

Conversation

@timzatko

@timzatko timzatko commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Reported as a 400 from /service/tombola-export during Oktoberfest 2026:

https://tw-calc.net/service/tombola-export?callback=jQuery351043490296483675417_...&tombolaId=60&prize=54931000&category=1&_=...

Bad Request (#400)
Level is not defined!

Cause

tombola-exporter.ts read the level as response.construction_id || data.enhance. An octoberfest bribe/upgrade carries neither: the request sends no enhance, and the bribe response has no construction_id and reports the level as enhance on itself (which is what the response interface comment has said all along).

The level therefore came out undefined — and jQuery does not send level= for that. ajaxExtend puts the ajax data through jQuery.extend(true, …), whose deep copy has an explicit else if ( copy !== undefined ) guard, so the key is deleted before jQuery.param ever runs. The server saw an absent param, not an empty one, and rejected the spin.

Regressed in 14a9728 (2021-03-31), which swapped response.enhance for data.enhance to fix the easter level. Normal spins do send enhance, so they kept working — only bribe/upgrade spins were lost, quietly, since 2021.

Fix

The level is the enhance the spin was played at. It is read from the request first and the response second, by first defined rather than with ||, because 0 is a real level (the un-enhanced spin).

construction_id is no longer a source at all. It is 0 on every octoberfest spin, and no recorded level has ever come from it — every tombola page from 2022 onward shows only levels 0, 25, 150 and 800, for octoberfest, independence and easter alike. It only ever appeared to work because || skipped it while it was falsy. Keeping it first with first-defined semantics would have started recording 0 for every independence spin, so this ordering matters.

Why it stayed hidden, and what changes so it cannot again

  • A spin with no resolvable level now reports through the error tracker (invisible to the player) carrying the request data and the response's key list, instead of firing a request that cannot succeed. The player's own stats are still kept — they do not use the level.
  • exportSpin passed only a success callback, so a rejected export vanished silently. It now warns and reports on every failure.

Tests

New tombola-exporter.spec.ts drives the real class through init() and a stubbed west.wof.WheelofFortune.prototype.process:

  • un-enhanced octoberfest spin (the exact payload from the report) → level: 0
  • octoberfest bribe → level: 25 read off the response
  • construction_id: 3 present with enhance: 0 → level: 0
  • both enhance sources set → the request's wins

Verified by mutation rather than by eye — each of these breaks the suite:

mutation tests failing
the original response.construction_id || data.enhance 2
|| instead of first-defined 2
construction_id put back as the first source 1
request/response precedence swapped 1

Note

The endpoint answers a successful export with an empty 200 body, so jQuery scores every export as a failure. Until the companion website change (timzatko/TW-Calc-Website#12) is deployed, the new failure reporting fires for every spin even when exports are landing.

🤖 Generated with Claude Code

https://claude.ai/code/session_017pYtZPqMDyRYtvJ7Jqxqw9

@timzatko
timzatko force-pushed the fix/tombola-level branch 2 times, most recently from efe4461 to 64d77be Compare September 10, 2026 14:58
The level was read as `response.construction_id || data.enhance`, and an
octoberfest bribe/upgrade carries neither: the request sends no `enhance`, and
the bribe response has no `construction_id`, reporting the level as `enhance` on
itself instead. The level came out undefined, and jQuery deletes an undefined
value from the ajax data rather than sending it empty, so /service/tombola-export
rejected every bribe spin with "Level is not defined!". Normal spins, which do
send `enhance`, were unaffected, so only part of each event went missing.
Regressed in 14a9728, which swapped `response.enhance` for `data.enhance` to fix
the easter level.

Read the enhance from the request first and the response second, by first
defined rather than with `||`, since 0 is a real level - the un-enhanced spin.
`construction_id` is no longer a source: it is 0 on every octoberfest spin and no
recorded level has ever come from it (every tombola page from 2022 on shows only
0, 25, 150 and 800), so reading it first would mask the real level. It only
appeared to work because `||` skipped it while it was falsy.

Two things kept this quiet. A spin with no resolvable level now reports through
the error tracker instead of firing a request that cannot succeed, keeping the
local stats, which do not use the level. And exportSpin passed only a success
callback, so a rejected export vanished; it now warns and reports on every
failure.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017pYtZPqMDyRYtvJ7Jqxqw9
@timzatko
timzatko merged commit cad7aa0 into main Sep 10, 2026
3 checks passed
timzatko added a commit that referenced this pull request Sep 10, 2026
The tombola service answers /service/tombola-export with a script of its
own rather than the jsonp callback jQuery generates - tombola-list does
the same, replying with a bare TW_Calc.addTombolaInfo(...) call - so
jQuery reports a parsererror for spins the server accepted. The failure
handler added in #68 turned each of those into a console error and a
/service/send-error report, once per spin.

Return early on parsererror with a debug-only log, and drop the error
tracking from the handler entirely; a status the export really failed
with is still warned about.


Claude-Session: https://claude.ai/code/session_01YAUg99g4KbYH58Pk1bSYat

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@timzatko
timzatko deleted the fix/tombola-level branch September 10, 2026 15:37
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.

1 participant