rwnx / pynonymizer

A universal tool for translating sensitive production database dumps into anonymized copies.
https://pypi.org/project/pynonymizer/
MIT License
101 stars 38 forks source link

TypeError: 'NoneType' object is not iterable #133

Closed nda888 closed 5 months ago

nda888 commented 8 months ago

Hello, As I try pynonymizer, and I have this issue

Traceback (most recent call last):
  File "fake-username.py", line 2, in <module>
    pynonymizer.run(input_path="stg-top-dashboard.sql", strategyfile_path="fake-accounts_user-username.yml",
  File "/home/abc/.local/lib/python3.8/site-packages/pynonymizer/pynonymize.py", line 109, in pynonymize
    strategy = strategy_parser.parse_config(
  File "/home/abc/.local/lib/python3.8/site-packages/pynonymizer/strategy/parser.py", line 196, in parse_config
    table_strategies = [
TypeError: 'NoneType' object is not iterable

I also attached my code fake-username.zip

What should I do for passing the above issue?

Many thanks An,

rwnx commented 8 months ago

Hi, I havent investigated this much but from a quick look, I think it might be that your strategyfile is not indented correctly.

This error is not very descriptive, though!

It is currently

tables:
accounts_user:
columns:
username: fake_username

when it should be:

tables:
  accounts_user:
    columns:
      username: fake_username
nda888 commented 8 months ago

Thanks rwnx, I will try follow your recommendation

nda888 commented 8 months ago

Hi, As I update and run again, I received this alert How can I define this function?

File "/home/nda/.local/lib/python3.8/site-packages/pynonymizer/strategy/parser.py", line 141, in __parse_update_column return FakeUpdateColumnStrategy( File "/home/nda/.local/lib/python3.8/site-packages/pynonymizer/strategy/update_column.py", line 72, in init raise UnsupportedFakeTypeError(fake_type, fake_args) pynonymizer.fake.UnsupportedFakeTypeError: Unsupported Fake type: fake_username: dict_keys([])

rwnx commented 5 months ago

Hi, This is some kind of syntax error in the strategyfile. likely something in yaml is a dictionary rather than a string like it's expecting. it's difficult to say without the updated strategyfile.

rwnx commented 5 months ago

I dont have a direct fix for this but I have improved some of the error reporting in this area a lot. Closing as this is now a tech support problem. You could look into the discussion feature https://github.com/rwnx/pynonymizer/discussions if you're looking for more help.