fix(game-data): degrade gracefully when items_game_cdn is unavailable#1
Merged
Conversation
items_game_cdn.txt was removed from SteamDatabase/GameTracking-CS2 and its raw.githubusercontent.com URL now 404s (see csfloat#250). items_game_cdn therefore stays false forever, and the enrichment guard in addAdditionalItemProperties bailed out entirely whenever it was falsy, silently dropping floatvalue/paintseed/paintindex/names for every inspected item. The CDN file only ever fed the optional imageurl field, which is not consumed by any downstream consumer in this fork. Split the guard so enrichment only requires items_game and csgo_english, and make the imageurl lookup conditional on items_game_cdn actually being loaded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
`items_game_cdn.txt` was removed from SteamDatabase/GameTracking-CS2. The download URL in `lib/game_data.js` now returns 404:
```
https://raw.githubusercontent.com/SteamDatabase/GameTracking-CS2/master/game/csgo/pak01_dir/scripts/items/items_game_cdn.txt
```
Confirmed via `gh api search/code` against SteamDatabase/GameTracking-CS2: the file no longer exists at any path (0 results).
Because of that, `this.items_game_cdn` stays `false` forever, and the guard in `addAdditionalItemProperties()`:
```js
if (!this.items_game || !this.items_game_cdn || !this.csgo_english) return;
```
aborts enrichment for every single item, so the price service receives responses with no usable float/paint data ("Inspect service returned no usable float data").
Upstream status
Open, unmerged upstream PR csfloat#250 ("Changed service to steamapis") addresses the same root cause by swapping the dead GameTracking-CS2 URL for a paid third-party API (`api.steamapis.com/image/items/730`, requires an API key). That's the right call for consumers who need `imageurl`, but it adds an external paid dependency we don't need: nothing in our price_service (`floatInspectClient.js`) reads `imageurl` — only `floatvalue`, `paintseed`, and `paintindex` are consumed.
Fix
Instead of replacing the CDN source, make it optional:
No new external dependency, no API key required, smaller diff than upstream csfloat#250.
Test plan
No test harness in this repo. Manual smoke test (documented here, not committed):
```js
const GameData = require('./lib/game_data.js');
const gd = Object.create(GameData.prototype);
gd.items_game = { paint_kits: {...}, items: {...}, rarities:{}, qualities:{}, sticker_kits:{}, keychain_definitions:{} };
gd.items_game_cdn = false; // simulates the permanent 404 state
gd.csgo_english = new Proxy({...}, LanguageHandler);
gd.schema = { originNames: [] };
gd.addAdditionalItemProperties(iteminfo);
```
Result with `items_game_cdn = false`:
Deploy plan (not executed by this PR)
Server compose builds this service from `../inspect` (sibling of `magicmarket_docker`):