tzssangglass commented on issue #7674:
URL: https://github.com/apache/apisix/issues/7674#issuecomment-1216123324

   In any case, I think the immediate cause is that `string.char()` is 
converting number that over the range 0..255.
   
   here is the test cases:
   
   ```
   use t::APISIX 'no_plan';
   
   add_block_preprocessor(sub {
       my ($block) = @_;
   
       if (!$block->request) {
           $block->set_value("request", "GET /t");
       }
   
       if (!defined $block->response_body) {
           $block->set_value("response_body", "passed\n");
       }
   
       if (!$block->no_error_log && !$block->error_log) {
           $block->set_value("no_error_log", "[error]");
       }
   
       $block;
   });
   
   repeat_each(1);
   no_long_string();
   no_root_location();
   log_level("info");
   
   run_tests;
   
   __DATA__
   
   === TEST 19: set additional_attributes
   --- config
       location /t {
           content_by_lua_block {
               local id_generator = require("opentelemetry.trace.id_generator")
               local trace_id =id_generator.new_ids()
   
               -- mock hex2bytes
               local function hex2bytes(str)
                   return (str:gsub('..', function (cc)
                       local n = tonumber(cc, 16)
                       if n then
                           -- hack n to be over the range 0..255
                           return string.char(256)
                       end
                   end))
               end
   
               hex2bytes(trace_id)
               ngx.say("done")
           }
       }
   --- response_body
   done
   
   ``` 


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to