I am trying to calculate this contour integral using the parameterization $z(t) = e^{it}$ where $0 \leq t \leq 2\pi$. We then have $z'(t) = ie^{it}$ so our contour integral becomes
$\int_{C}f(z)dz = \int_{0}^{2\pi}f(z(t))z'(t)dt = \int_{0}^{2\pi}\frac{e^{it}}{2(e^{it})^2+1}ie^{it}dt$
Now if I perform the substitution $u = e^{it}$, then our integral becomes $\int_{1}^{1}\frac{u}{2u^2 + 1}du = 0$, however Mathematica evalutes this integral to be $i\pi$. I believe there must be some assumption i'm making here that isn't valid. Any insight would be greatly appreciated.
The error comes in the $u$ substitution. Note that after some work,$$\int_0^{2\pi}\frac{e^{it}}{2(e^{it})^2+1}ie^{it}dt=\int_0^{2\pi} \frac{-\sin 2t}{5 + 4\cos 2t}dt + i\int_0^{2\pi}\frac{2+\cos 2t}{5 + 4\cos 2t}dt$$
I.e., its real and imaginary parts are just ordinary real integrations. But when you substituted $u = e^{it}$, you introduced a variable of integration that was not real again. In fact, you undid the very "substitution" that is used to define complex integration in the first place. Since your $u$ substitution is a complex variable, it has to be treated as a complex integration again, which means it is not an integration along an interval in the real line, but along a contour in $\Bbb C$ (in particular, that same unit circle $C$ you started with). It may start and end at $1$, but it takes a loop to do so.
Integration around a closed contour only reliably gives $0$ if the function is analytic on the curve and its interior (Cauchy's theorem), but this function has two poles inside.