Left side is finite but right side becomes infinte despite using correct series expansions I want to evaluate (for integer $n,p$)
$$ 
L_p = \sum_{m=1}^{n-1} \ln \left(  4 \sin^2 \frac{m \pi }{n}\right)  e^{- 2\pi i p m
/n}
$$
and I have got two tools
$$ 
\sum_{k=1}^{\infty} \frac{\cos kx}{k} = - \frac{1}{2} \ln \left(4 \sin ^2 \frac{x}{2}\right) 
$$
and
$$ 
\sum_{k=1}^{n-1} r^{k} \cos kx =  \frac{1 - r \cos x - r^{n} \cos (nx) + r^{n+1} \cos (nx -x)}{r^2 + 1 - 2 r \cos x} -1
$$
both of which are formulas tabulated in Gradshteyn, and I've individually
verified them. (I couldn't derive the first myself, but second was easy to prove.)
Plugging in $L_p$, we get
$$ 
L_p =  \sum_{m=1}^{n-1} \left[-2 \sum_{k=1}^{\infty}  \frac{\cos \left(  k \cdot  \frac{2 m \pi}{n}\right)}{k}\right] e^{- 2\pi i p m/n}
$$
and exchanging the sum (as I understand can always be done according to this
question), this becomes
$$ 
L_p\; = -2\sum_{k=1}^{\infty}  \frac{1}{k} \cdot  \left[  \sum_{m=1}^{n-1} e^{-2 \pi i p m/n} \cdot  \cos \left( m \cdot  \frac{2\pi k}{n}\right)\right]
$$
Setting $r = e^{-2 \pi i p/n}$, $x= 2\pi k/n$ and using above formula, the inner sum becomes $-1$.  which means
$$ 
L_p = 2 \sum_{k=1}^{\infty} \frac{1}{k}  
$$
which is of course divergent, but the left side was finite because $m=0$ never
occurs in the sum.
What is going wrong, and how can I get $L_p$?


$$  L_p\; = -2\sum_{k=1}^{\infty}  \frac{1}{k} \cdot  \left[  \sum_{m=1}^{n-1} e^{-2 \pi i p m/n} \cdot  \cos \left( m \cdot  \frac{2\pi k}{n}\right)\right] $$ Setting $r = e^{-2 \pi i p/n}$, $x= 2\pi k/n$ and using above formula, the inner sum becomes $-1$.

I did not attempt to reproduce the calculation, but it is not possible that you could have eliminated two unknowns, $p$ and $k$, by summing over $m$. Also you didn't tell us what $p$ is.
For example set $p=0$ then all of the $r=1$ so you are left with cosines. What I think you have done is to neglect $p$ when you did that expansion.

which
means $$  L_p = 2 \sum_{k=1}^{\infty} \frac{1}{k}   $$ which is of
course divergent, but the left side was finite because $m=0$ never
occurs in the sum.
What is going wrong, and how can I get $L_p$?

I confirmed numerically that your second formula for $L_p$ was correct, and also the expansions you're using, so I would look at the final expansion where you remove both of $p$ and $k$.
See here for an online-runnable version of the numeric checks.
