# TypeError: can not serialize 'Undefined' object

**URL:** <https://discourse.getdbt.com/t/typeerror-can-not-serialize-undefined-object/13818>\
**Category:** Help\
**Tags:** dbt-core\
**Created:** [June 14, 2024, 7:57am UTC](https://discourse.getdbt.com/t/typeerror-can-not-serialize-undefined-object/13818 "2024-06-14T07:57:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mateusz](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mateusz](https://discourse.getdbt.com/u/mateusz)\
**Post date:** [June 14, 2024, 7:57am UTC](https://discourse.getdbt.com/t/typeerror-can-not-serialize-undefined-object/13818/1 "2024-06-14T07:57:14Z")

</div>

## The problem

I work on some dbt models locally using-dbt core. Until yesterday everything worked fine. At some point of time commands like dbt build, dbt test etc. started to return error as displayed below. I have no idea what can I do to fix that problem.

Tech context:  
OS: Ubuntu24.04 (WSL)  
Python: 3.11.0  
dbt-core: 1.7.10  
databricks:1.7.10  
virtual environment: poetry 1.8.1

## I took following steps and all of them didn’t help:

- Recreated virtual environment
- Reinstalled python
- Reinstalled msgpack
- Run commands with --no-partial-parse

## Error message

```auto
07:25:47 Encountered an error:
can not serialize 'Undefined' object
07:25:47 Traceback (most recent call last):
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/cli/requires.py", line 91, in wrapper
    result, success = func(*args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/cli/requires.py", line 76, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/cli/requires.py", line 169, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/cli/requires.py", line 198, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/cli/requires.py", line 245, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/cli/requires.py", line 271, in wrapper
    ctx.obj["manifest"] = parse_manifest(
                          ^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/parser/manifest.py", line 1798, in parse_manifest
    manifest = ManifestLoader.get_full_manifest(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/parser/manifest.py", line 318, in get_full_manifest
    manifest = loader.load()
               ^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/parser/manifest.py", line 567, in load
    self.write_manifest_for_partial_parse()
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/parser/manifest.py", line 752, in write_manifest_for_partial_parse
    manifest_msgpack = self.manifest.to_msgpack(extended_mashumaro_encoder)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 71, in __mashumaro_to_msgpack__
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/dbt/parser/manifest.py", line 139, in extended_mashumaro_encoder
    return msgpack.packb(data, default=extended_msgpack_encoder, use_bin_type=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mateusz/databricks/.venv/lib/python3.11/site-packages/msgpack/ __init__.py", line 36, in packb
    return Packer(**kwargs).pack(o)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "msgpack/_packer.pyx", line 294, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 300, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 297, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 231, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 231, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 231, in msgpack._cmsgpack.Packer._pack
  [Previous line repeated 1 more time]
  File "msgpack/_packer.pyx", line 291, in msgpack._cmsgpack.Packer._pack
TypeError: can not serialize 'Undefined' object

```

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [June 14, 2024, 12:59pm UTC](https://discourse.getdbt.com/t/typeerror-can-not-serialize-undefined-object/13818/2 "2024-06-14T12:59:50Z")

</div>

This can be a lot of stuff, but the most common problem I see with this error is not using quotes inside the config block

So, for example, this

```auto
{{ config(
    materialized=incremental
) }}

```

Should be

```auto
{{ config(
    materialized='incremental'
) }}

```

Or this

```auto
{{ config(
    options={
        partition_by : ['PropertySetDetailSeasonID']
    }   
) }}

```

Should be

```auto
{{ config(
    options={
       'partition_by': ['PropertySetDetailSeasonID']
    }   
) }}

```

Check if you have something like that

---

<div class="post-metadata">

**Author:** ![mateusz](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mateusz](https://discourse.getdbt.com/u/mateusz)\
**Post date:** [June 15, 2024, 6:13am UTC](https://discourse.getdbt.com/t/typeerror-can-not-serialize-undefined-object/13818/3 "2024-06-15T06:13:50Z")

</div>

That was the reason for the error. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [June 22, 2024, 6:13am UTC](https://discourse.getdbt.com/t/typeerror-can-not-serialize-undefined-object/13818/4 "2024-06-22T06:13:54Z")

</div>

Closed on June 22, 2024, 6:13am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
