Skip to content

Logger breaks on nested objects #1302

Description

@mik115

Hi,
I'm facing a real strange problem:
after updating to 0.32.0 the logging service breaks when a nested object is passed.

es:

   const gcloud = require('gcloud')({
        projectId: 'project_id',
        keyFilename: 'fileKey.json',
    });
    const logging = gcloud.logging();

    const resource = {
         type: 'gae_app',
         labels: {
              module_id: 'Test',
              version_id: '1'
          }
    };

   const log = logging.log('test');

   const entry = log.entry(resource, {
     message: 'messaggio di test',
     data: {
          error: 'no error',
           log: 'test'
      }
   });
   entry.severity = "INFO";
   //code breaks here
   log.write(entry, (err, apiResponse) =>{
       console.log(err, apiResponse);
   });

Thanks in advance

Activity

  1. stephenplusplus commented on May 10, 2016

    @stephenplusplus
    Contributor

    I'll look right into this, thanks for reporting!

  2. mik115 commented on May 10, 2016

    @mik115
    Author

    The raised error is:

      /Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2440
                            throw Error(this+"#"+keyOrObj+" is not a field: undefined");
                            ^
    
    Error: .google.protobuf.Value#fields is not a field: undefined
    at Error (native)
    at MessagePrototype.set (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2440:35)
    at MessagePrototype.set (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2434:38)
    at Message (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2363:34)
    at ProtoBuf.Reflect.ElementPrototype.verifyValue (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:1877:28)
    at new ProtoBuf.Map.Map (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:4894:46)
    at ProtoBuf.Reflect.FieldPrototype.verifyValue (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:3427:28)
    
  3. stephenplusplus commented on May 10, 2016

    @stephenplusplus
    Contributor

    PR sent: #1303

    Please try it out!

    $ npm install --save stephenplusplus/gcloud-node#spp--1302
  4. mik115 commented on May 10, 2016

    @mik115
    Author

    It works this way!
    Great!

  5. 1N50MN14 commented on May 18, 2016

    @1N50MN14

    @stephenplusplus didn't this one make it to 0.33.0 on npm? facing the same issue here in my docker container

  6. stephenplusplus commented on May 18, 2016

    @stephenplusplus
    Contributor

    It did. Can you paste the code to reproduce and the error?

  7. 1N50MN14 commented on May 18, 2016

    @1N50MN14

    Yes one sec, ps logging breaks with entries containing boolean fields as well throwing the error:

    /src/node_modules/gcloud/node_modules/grpc/node_modules/protobufjs/dist/ProtoBuf.js:2440
                                throw Error(this+"#"+keyOrObj+" is not a field: undefined");
                                ^
    
    Error: .google.protobuf.Value#booleanValue is not a field: undefined
  8. 1N50MN14 commented on May 18, 2016

    @1N50MN14
      bigquery.createDataset(datasetName, function(err, dataset) {
        if (err && err.code !== 409)
          throw err;
    
        logger.createSink(loggerName, {
          destination: bigquery.dataset(datasetName)
        }, function(err, sink){
          if (err && err.code !== 409)
            throw err;
    
          console.log('logger service started.');
    
          log = logger.log('syslogs');
    
          nc.subscribe('events.logger.error', function(data){
            _syslog(data);
          })
        });
    
      function _syslog(data)
      {    
        var entry = log.entry({}, data);
        log.write(entry, (err, apiResponse) =>{
               console.log(err, apiResponse);
          });
      }

    The data I'm writing looks like this:

    { error: 'Unprocessable Entity',
      message: 'Please check your phone number and try again.',
      code: 422,
      retry: false,
      whoami:
       { image: 'service-sms',
         port: 5000,
         online: true,
         host: '46.101.140.203',
         name: 'sms',
         region: 'local',
         version: '0.0.1',
         dockerhost: '172.17.0.5',
         publichost: '46.101.140.203',
         ports: [ 5000 ] },
      severity: 'INFO',
      origin: 'server',
      method: 'send',
      request: { to: 'xx', text: 'hello world' } }
  9. stephenplusplus commented on May 18, 2016

    @stephenplusplus
    Contributor

    Thanks for the details @1N50MN14 -- could you try out #1329?

    $ npm install --save stephenplusplus/gcloud-node#spp--1302-2
  10. 1N50MN14 commented on May 18, 2016

    @1N50MN14

    Yup, one sec please

  11. 1N50MN14 commented on May 18, 2016

    @1N50MN14

    It's throwing this error:

    /src/node_modules/gcloud/node_modules/grpc/node_modules/protobufjs/dist/ProtoBuf.js:2440
                                throw Error(this+"#"+keyOrObj+" is not a field: undefined");
                                ^
    
    Error: .google.api.MonitoredResource#image is not a field: undefined
    

    (It's also screaming about autoPaginate elsewhere in my code not being a function, wondering if the datastore query API has changed)

  12. 1N50MN14 commented on May 18, 2016

    @1N50MN14

    grr sorry my bad sec please

  13. 1N50MN14 commented on May 18, 2016

    @1N50MN14

    Ok that seemed to have fixed this error! the callback returns error 400 though, I'm not sure why that is

  14. 11 remaining items

  15. added a commit that references this issue on Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: loggingIssues related to the Cloud Logging API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions