You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@hertzbeat.apache.org by "orangeCatDeveloper (via GitHub)" <gi...@apache.org> on 2026/08/10 01:26:53 UTC

[PR] [fix] strip NUL bytes before tdengine history insert [hertzbeat]

orangeCatDeveloper opened a new pull request, #4310:
URL: https://github.com/apache/hertzbeat/pull/4310

   ## What's changed?
   
   Fixes #1481: Windows SNMP interface descriptions carry NUL padding bytes (`\^@`). The TDengine history storage builds its INSERT by hand, so the NUL reached the SQL text, TDengine rejected it with error 216, and the whole batch was lost — including the healthy rows.
   
   Fix in `TdEngineDataStorage.formatStringValue`, the single choke point all string values, labels json and the instance tag pass through:
   
   - strip `` before anything else (only NUL — tabs/newlines are legitimate data)
   - truncate the logical value **before** SQL-escaping: the old escape-then-truncate order could cut an escape pair like `\'` in half, leaving a dangling backslash that escapes the closing quote and kills the batch the same way
   
   Only TDengine is affected: the other history backends use typed clients / JSON / line protocol instead of hand-built SQL.
   
   Verified against a real TDengine 3.3.5.0 with a metric whose string value ends in ``:
   
   ```
   before: TDengine ERROR (216) ... syntax error near ''Software Loopback Interface 1' — 0 rows stored
   after:  no errors — rows stored, value clean: 'Software Loopback Interface 1'
   ```
   
   ## Checklist
   
   - [x]  I have read the [Contributing Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide)
   - [x]  I have written the necessary doc or comment.
   - [x]  I have added the necessary unit tests and all cases have passed.
   
   ## Add or update API
   
   - [ ] I have added the necessary [e2e tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have passed.
   


-- 
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@hertzbeat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: notifications-help@hertzbeat.apache.org


Re: [PR] [fix] strip NUL bytes before tdengine history insert [hertzbeat]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 merged PR #4310:
URL: https://github.com/apache/hertzbeat/pull/4310


-- 
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@hertzbeat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: notifications-help@hertzbeat.apache.org