In Fermion Path Integrals And Topological Phases Witten showed that for a massless Dirac fermion in $2+1$ dimensions
$$S[\bar{\psi},\psi]=\int d^{3}x\bar{\psi}iD\!\!\!\!/_{A}\psi,$$
where $A$ is a $U(1)$ background gauge field, the partition function should be
$$\mathcal{Z}=|\det(iD\!\!\!\!/_{A})|\exp\left\{-\frac{i\pi\eta(A)}{2}\right\},$$
where $\eta(A)$ is the APS eta-invariant introduced in Spectral asymmetry and Riemannian Geometry. This function measures the asymmetry of the spectrum of the Dirac operator. In a sloppy language, $\eta(A)$ equals to the number of positive modes of $iD\!\!\!\!/_{A}$ minus the number of negative modes of $iD\!\!\!\!/_{A}$.
The phase factor comes from Pauli-Villars regularization. To be specific, since the formal expression of the partition function
$$\mathcal{Z}=\prod_{\lambda\in\mathrm{Spec}}\lambda,$$
where each $\lambda$ is an eigenvalue of the Hermitian operator $iD\!\!\!\!/_{A}$, is an infinite product, the overall sign of the partition function is not defined. One can regularize it by adding the Lagrangian a Pauli-Villars regulator
$$\mathcal{L}_{\mathrm{reg}}=\lim_{M\rightarrow\infty}\left(\bar{\chi}iD\!\!\!\!/_{A}\chi+iM\bar{\chi}\chi\right),$$
where $\chi$ is a ghost scalar satisfying the Dirac equation. Then, using the formula
$$\mathrm{Arg}(zw)=\mathrm{Arg}(z)+\mathrm{Arg}(w)\,\,\,\mathrm{mod}\,\,2\pi$$
one finds that the regularized partition function indeed becomes
$$\mathcal{Z}=|\det(iD\!\!\!\!/_{A})|\exp\left\{-\frac{i\pi\eta(A)}{2}\right\}.$$
However, there is still a problem when one performs a large gauge transformation. Under a large gauge transformation, there can be a net spectral flow of the Dirac operator. This was introduced in Parity Violation and Gauge Noninvariance of the Effective Gauge Field Action in Three-Dimensions.
To be specific, let us start from $A$. Under a large gauge transformation $\Phi$, $A$ is transformed to $A^{\Phi}$. Then, one can interpolate the two and make a gauge field
$$A_{s}=(1-s)A+sA^{\Phi},$$
where $s\in[0,1]$ parametrizes the spectral flow under a large gauge transformation. Here, $A$ and $A^{\Phi}$ are gauge equivalent.
For example, if one of the positive modes of $iD\!\!\!\!/_{A}$ flows through a zero-mode to the negative spectrum, then $\eta(A)$ would jump by $\pm 2$.
As a result, the sign of the partition function would flip accordingly. However, one would expect that the spectrum at $s=0$ is identical to the spectrum at $s=1$ since the two are related via a gauge transformation.
The existence of the spectral flow is guaranteed by the APS-index theorm. The number of eigenmodes flowing through $0$ equals to a Dirac index $\Delta$ in four dimensional spacetime. i.e. one views the $2+1$ dimensional spacetime as the boundary of a $3+1$ dimensional bulk. In other words, under a large gauge transformation, the partition transforms as
$$\mathcal{Z}\rightarrow\mathcal{Z}(-1)^{\Delta}.$$
However, there is no obvious reason why the index in the bulk can be an even number. This was also discussed in Anomalies and Odd Dimensions.
Does this mean that the massless Dirac fermion in $2+1$ dimensions suffer from a gauge anomaly?