Kong / Kong/developer.konghq.com
Support references to scripts for Konnect API in entity_example blocks
- Dominant language
- Ruby
- Stars
- 28
- Forks
- 121
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 313
Description
## Jobs to be done (optional)
**_FYI: Claude helped diagnose the issue and propose a solution_**
Docs authors should be able to write entity_example blocks that reference a script loaded from a file (e.g. $FUNCTION_LUA set via export FUNCTION_LUA=$(cat function.lua)) and have the auto-rendered konnect-api curl example produce valid, working JSON — the same way the kongctl format already does.
## Definition of done
Fix the konnect-api curl-rendering pipeline (app/_includes/components/entity_example/format/snippets/konnect-api.md + app/_plugins/filters/escape_env_variables.rb) so that env vars containing multi-line content (newlines, embedded quotes) are safely JSON-escaped when spliced into the generated --data '...' payload, instead of being spliced as a raw, unescaped shell variable.
## Information
Today the filter regex-replaces $UPPERCASE_VAR tokens by breaking out of the JSON double-quotes with single quotes ("access": ["$FUNCTION_LUA"] → "access": ["'$FUNCTION_LUA'"]), which only works for single-line, quote-free values. This should be replaced with (or supplemented by) an approach that JSON-escapes the variable's value at render/shell-eval time — e.g. generating a jq --arg based command for these cases — without regressing existing single-line examples ($CONSUMER_ID, etc.) that rely on the current behavior.
Diana ran into this issue while testing the OTEL policy examples. kongctl worked fine, but the Konnect API couldn't pass the script env var: `Bad Request: request body has an error: failed to decode request body: invalid character '\n' in string literal`
## Due date (optional)
## Size
Contributor guide
No contributing guide indexed for this repository
Research direction
Read app/_includes/components/entity_example/format/snippets/konnect-api.md and app/_plugins/filters/escape_env_variables.rb, then inspect how entity_example values become the generated curl --data payload. Verify the rendered command with multiline and quote-containing script variables, while preserving existing single-line examples such as $CONSUMER_ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby, shell
- Domain
- documentation, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100