Skip to content

Log incorrectly prints [Circular] for object property when it shares reference with another property in the same object #228

Closed
@CorieW

Description

@CorieW

Same problem was seen in firebase/firebase-functions#1510 for JS/TS

Test case

from firebase_functions import https_fn
from firebase_functions import logger

@https_fn.on_request()
def on_request_example(req: https_fn.Request) -> https_fn.Response:
    common_data = {"foo": "bar"}
    obj1 = {
        "data": common_data,
    }
    obj2 = {
        "data": common_data,
    }
    logger.debug("TEST 1", {"obj1": obj1, "obj2": obj2})
    return https_fn.Response("Oki doki")

Steps to reproduce

  • Call the function
  • View the logs

Expected behavior

When calling the function (e.g. locally) it should log with the json payload:

{
  "obj1": { "data": { "foo": "bar" } },
  "obj2": { "data": { "foo": "bar" } },
  "severity": "DEBUG",
  "message": "TEST 1"
}

Actual behavior

Instead it prints the following payload:

{
  "obj1": { "data": { "foo": "bar" } },
  "obj2": { "data": "[Circular]" },
  "severity": "DEBUG",
  "message": "TEST 1"
}

Were you able to successfully deploy your functions?

Yes, I had the same issue when viewing the logs in the log explorer.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriagedTriaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions