DFT of a complex sinusoid
The last expression (sum of  a geometric series) is a common abuse of notations: it should have been:


$N$ if $k= k_0$
$f(r)=\frac{1-r^N}{1-r}$ with $r=e^{-j 2\pi(k-k_0)/N}$ if $k\neq k_0$


Indeed, as you correctly remarked, numerator and denominator would vanish for $r=1$ (or $k= k_0$), so the fraction is not "theoretically" defined. However, it is consistent to the limit, as $f(r)\to N$ as $r\to 1$  since $e^{-j 2\pi(k-k_0)/N}\to 1$ when $k \to k_0$ (allowing real $k$).

Mathematically, the fraction gives one single expression, defined by continuity at $k= k_0$. It is a bit like saying that $\frac{r^2-1}{r-1}$, not defined at $r=1$, is in some way equivalent  to $r+1$ (using $r^2-1=(r-1)(r+1)$  and wrongfully simplifying the fraction. This is not correct, but makes sense.