You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "AlinsRan (via GitHub)" <gi...@apache.org> on 2026/06/12 03:55:55 UTC
[PR] fix(elasticsearch-logger): guard os.date against invalid index template [apisix]
AlinsRan opened a new pull request, #13542:
URL: https://github.com/apache/apisix/pull/13542
### What this fixes
The elasticsearch-logger dynamic-index feature (`index` may contain `{time_format}` placeholders) passes the user-controlled format straight to `os.date`:
```lua
-- apisix/plugins/elasticsearch-logger.lua, replace_time()
local time = os_date(time_format)
if not time then ... end
```
`os.date` **raises** (rather than returning `nil`) on some invalid `strftime` escapes, so a crafted `index` value throws in the log phase instead of degrading gracefully — the existing `if not time` guard never gets a chance to run.
### Change
Wrap the `os.date` call in `pcall` and fall back to an empty replacement on failure, matching the intent of the existing nil-check.
### Checklist
- [x] I have explained the need for this PR and the problem it solves
- [x] I have explained the changes or the new features added to this PR
- [ ] I have added tests corresponding to this change
- [x] I have updated the documentation to reflect this change (N/A)
- [x] I have verified that the changes pass the existing tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(elasticsearch-logger): guard os.date against invalid index template [apisix]
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan merged PR #13542:
URL: https://github.com/apache/apisix/pull/13542
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org