DP on DAGs assumes you can order nodes so each depends only on earlier nodes. Cycles break this because depends on and depends on . For shortest paths with cycles, use Dijkstra (no negative weights) or Bellman-Ford (handles negative weights).
For longest paths with cycles, you need cycle detection first. If the graph has cycles but you know it is a DAG (problem statement guarantees it), you can use DP confidently. Otherwise, check for cycles before applying DP.