Skip to main content

272 posts tagged with "Issues"

Common Issues and Troubleshooting

View All Tags

Fixed: "ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails" in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails means the row you're deleting is still in use: another table points at it through a foreign key, and that foreign key forbids the delete. The message even tells you which table and column. This post reads it piece by piece, finds the rows that block the delete, shows two ways to clear them, and turns the error into a 409 Conflict in a .NET C# API.

Fixed: "ERROR 1062 (23000): Duplicate entry 'adapters' for key 'categories.IX_categories_Name'" in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

ERROR 1062 (23000): Duplicate entry … for key … means a unique index refused a value that already exists. Usually that's the index doing its job. The surprise in my case was which value counted as a duplicate: MySQL refused adapters because Adapters was already there. This post explains why, how to choose the behaviour you want, and how to handle the error cleanly in MySQL and in a .NET C# API.

Fixed: "ERROR 3819 (HY000): Check constraint 'CK_products_UnitPrice' is violated." in MySQL

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

MySQL enforces CHECK constraints, and it tells you when a row breaks one: ERROR 3819 (HY000): Check constraint '…' is violated. I met it twice in one afternoon: first when an EF Core migration tried to add constraints to a table that already held a bad row, then when a new row broke the rule. Both have the same cause and the same kind of fix, and in a .NET C# API the error can become a clear 400 Bad Request instead of a crash.

Fixed: "ERROR 1064 (42000): You have an error in your SQL syntax … near 'IF NOT EXISTS(SELECT * FROM `__EFMigrationsHistory`'" in an EF Core Idempotent Migration Script

· 13 min read
Jagdish Kumawat
Founder @ Dewiride

An EF Core migration script made with dotnet ef migrations script --idempotent failed in MySQL 9.7 at line 8 with ERROR 1064 (42000). Oracle's EF Core provider for MySQL writes the script's "skip what's already applied" checks as SQL Server-style IF NOT EXISTS(…) BEGIN … END blocks, and MySQL accepts that kind of block only inside stored procedures and other stored programs. The fix is a plain script that starts at the database's last applied migration.

Fixed: "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate" in Python on macOS

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A Python script on my Mac couldn't open an HTTPS address: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate. curl opened the same address without a problem. Python from python.org brings its own OpenSSL, which doesn't use the Mac's certificates, and the fix is a script that comes with it: Install Certificates.

Fixed: Git Shows Every Line Changed in Files from dotnet new (CRLF Line Endings)

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

I changed four lines of a .NET project file, and Git reported 32. The ASP.NET Core Web API template creates its files with Windows line endings (CRLF), even on a Mac, while the dotnet commands that later edit a file save it with LF. To Git, every line of such a file looked different. One .gitattributes file, as Git's own documentation describes, stores every text file with LF and ends the noise.

Fixed: error CA1852: Type 'WeatherForecast' can be sealed because it has no subtypes in its containing assembly and is not externally visible

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

The first build of a brand-new .NET 10 Web API failed with error CA1852 on the template's own WeatherForecast record. The solution turns on Microsoft's recommended code-quality rules and treats warnings as errors, and one of those rules asks for types like this one to be sealed. Adding that one word fixes it.

Fixed: error NU1008: The following PackageReference items cannot define a value for Version

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

I created an ASP.NET Core Web API project inside a .NET 10 solution that manages package versions centrally, and the template's own restore failed with error NU1008. The template writes a package version into the project file, which central package management doesn't allow. Moving that one version to Directory.Packages.props fixes it.