Title: fix: Encode non-finite floats in feature server JSON responses by Zhuoxi2000 · Pull Request #6930 · feast-dev/feast · GitHub
Open Graph Title: fix: Encode non-finite floats in feature server JSON responses by Zhuoxi2000 · Pull Request #6930 · feast-dev/feast
X Title: fix: Encode non-finite floats in feature server JSON responses by Zhuoxi2000 · Pull Request #6930 · feast-dev/feast
Description: What this PR does / why we need it: A stored NaN or +/-inf float value makes POST /get-online-features fail with HTTP 500 (ValueError: Out of range float values are not JSON compliant). _value_to_native returns raw Python floats, and JSONResponse serializes with allow_nan=False, so one non-finite value fails the whole multi-feature response. The SDK get_online_features().to_dict() path serves the same value fine. /search and /retrieve-online-documents share convert_response_to_dict and are affected too. This PR encodes non-finite values as the protobuf JSON mapping strings "NaN", "Infinity" and "-Infinity". This applies to: scalar double_val / float_val double_list_val, float_list_val, double_set_val, float_set_val (element-wise) Finite values are unchanged, and lists without non-finite values still go through a plain list(...). Nested list_val / map_val / struct_val values get the fix through the existing recursion. The convert_response_to_dict docstring documents the encoding. If maintainers would rather emit null for non-finite values (the behaviour while ORJSONResponse was in use), this is a one-line change in _float_to_native. Not covered here: RemoteOnlineStore._build_online_response_from_json infers value types from the JSON, so it would read the encoded strings as strings and rejects a list that mixes numbers and strings. This path already failed before (the server returned 500), and null would not round-trip through it either. I can follow up on the client side once the encoding is settled. Which issue(s) this PR fixes: No separate issue; the bug is described above. Checks I've made sure the tests are passing. My commits are signed off (git commit -s) My PR title follows conventional commits format Testing Strategy Unit tests Integration tests Manual tests Testing is not required for this change New tests: tests/unit/test_feature_server.py::test_get_online_features_serves_non_finite_float[inf|-inf]: writes +/-inf to the online store, checks that the SDK serves it, then checks that /get-online-features returns 200 with "Infinity" / "-Infinity" and status PRESENT. tests/unit/test_feature_server_utils.py: covers NaN/inf/-inf for double_val and float_val, the four float/double list and set types, and a json.dumps(..., allow_nan=False) round trip of convert_response_to_dict. From sdk/python: python -m pytest tests/unit/test_feature_server_utils.py tests/unit/test_feature_server.py -q Without the fix (the tests only): 13 failed, 97 passed. Every new test fails, and the endpoint test fails with assert 500 == 200 / Out of range float values are not JSON compliant. With the fix: 110 passed. tests/unit/test_proto_json.py, tests/unit/test_feature_server_async.py and tests/unit/infra/feature_servers/test_mcp_server.py also pass (28 passed). ruff check and ruff format --check (0.16.9) are clean on the changed files. Misc
Open Graph Description: What this PR does / why we need it: A stored NaN or +/-inf float value makes POST /get-online-features fail with HTTP 500 (ValueError: Out of range float values are not JSON compliant). _value_to_n...
X Description: What this PR does / why we need it: A stored NaN or +/-inf float value makes POST /get-online-features fail with HTTP 500 (ValueError: Out of range float values are not JSON compliant). _value_to_n...
Opengraph URL: https://github.com/feast-dev/feast/pull/6930
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d44fbfbb-ea75-9226-20c9-79995ed71c81 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | EC7C:264CD6:E9029C:1351B14:6AFE9883 |
| html-safe-nonce | 04e2e93b6318a111043745c416e77d025e71b600a9706284f17e602468367c0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzdDOjI2NENENjpFOTAyOUM6MTM1MUIxNDo2QUZFOTg4MyIsInZpc2l0b3JfaWQiOiI1MzUyMzMyNTU2NTAwMDcxNzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8a368974d7cac50297eca0aa59c53f2e24fe117489275443698b7d3f23eb35e1 |
| hovercard-subject-tag | pull_request:4715842659 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/feast-dev/feast/pull/6930/files |
| twitter:image | https://avatars.githubusercontent.com/u/113824357?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/113824357?s=400&v=4 |
| og:image:alt | What this PR does / why we need it: A stored NaN or +/-inf float value makes POST /get-online-features fail with HTTP 500 (ValueError: Out of range float values are not JSON compliant). _value_to_n... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/feast-dev/feast git https://github.com/feast-dev/feast.git |
| octolytics-dimension-user_id | 57027613 |
| octolytics-dimension-user_login | feast-dev |
| octolytics-dimension-repository_id | 161133770 |
| octolytics-dimension-repository_nwo | feast-dev/feast |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 161133770 |
| octolytics-dimension-repository_network_root_nwo | feast-dev/feast |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width