as you do not show the code to call the function, hard to guess

going by the highlighted line, should be something like
Code:
somevar = get_network_user
your variable must be of type string

but also username should be a string

but on testing the first did not appear to cause a problem, so the problem was username