pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/apache/apisix/pull/13281

href="https://github.githubassets.com/assets/actions-902e75f4f51a80db.css" /> fix(core/json): stably_encode fails to encode cjson.null values by rickyxucn · Pull Request #13281 · apache/apisix · GitHub
Skip to content

fix(core/json): stably_encode fails to encode cjson.null values#13281

Open
rickyxucn wants to merge 1 commit intoapache:masterfrom
rickyxucn:fix-stably-encode-cjson-null
Open

fix(core/json): stably_encode fails to encode cjson.null values#13281
rickyxucn wants to merge 1 commit intoapache:masterfrom
rickyxucn:fix-stably-encode-cjson-null

Conversation

@rickyxucn
Copy link
Copy Markdown

@rickyxucn rickyxucn commented Apr 22, 2026

The stably_encode function used dkjson.encode directly, which does not recognize cjson.null (a userdata) and fails to encode it properly.

This fix adds a convert_cjson_null helper that recursively converts cjson.null to dkjson.null before encoding. This ensures tables containing cjson.null values can be stably encoded as valid JSON with null literals.

Also added 4 test cases in t/core/json.t to cover:

  • simple table with cjson.null
  • nested table with cjson.null
  • encoding stability with cjson.null
  • top-level cjson.null encoding

Description

Which issue(s) this PR fixes:

Fixes #

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Apr 22, 2026
The stably_encode function used dkjson.encode directly, which does not
recognize cjson.null (a userdata) and fails to encode it properly.

This fix adds a convert_cjson_null helper that recursively converts
cjson.null to dkjson.null before encoding. This ensures tables containing
cjson.null values can be stably encoded as valid JSON with null literals.

Also added 4 test cases in t/core/json.t to cover:
- simple table with cjson.null
- nested table with cjson.null
- encoding stability with cjson.null
- top-level cjson.null encoding

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rickyxucn rickyxucn force-pushed the fix-stably-encode-cjson-null branch from 1ecd73b to 2dbb890 Compare April 23, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy