{"record":{"id":"6af452b85f10e0ce","repo":"abpframework/abp","slug":"parametername-has-a-default-value","errorCode":null,"errorMessage":"{parameterName} has a default value!","messagePattern":"(.+?) has a default value!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/Check.cs","lineNumber":355,"sourceCode":"            throw new ArgumentException($\"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}\");\n        }\n\n        return value;\n    }\n\n    public static T NotDefaultOrNull<T>(\n        [System.Diagnostics.CodeAnalysis.NotNull] T? value,\n        [InvokerParameterName][NotNull] string parameterName)\n        where T : struct\n    {\n        if (value == null)\n        {\n            throw new ArgumentException($\"{parameterName} is null!\", parameterName);\n        }\n\n        if (value.Value.Equals(default(T)))\n        {\n            throw new ArgumentException($\"{parameterName} has a default value!\", parameterName);\n        }\n\n        return value.Value;\n    }\n}\n","sourceCodeStart":337,"sourceCodeEnd":361,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/Check.cs#L337-L361","documentation":"Thrown by Check.NotDefaultOrNull<T> when the nullable struct is non-null but its value equals default(T) (e.g. Guid.Empty, 0, DateTime.MinValue). It is the second guard in that method and exists because default values of structs are often semantically 'unset'. ArgumentException carries parameterName.","triggerScenarios":"Calling Check.NotDefaultOrNull(value, nameof(value)) where value is Guid.Empty, 0, DateTime.MinValue, default(int), etc.","commonSituations":"A Guid id left as Guid.Empty by deserialization, a date defaulting to 0001-01-01, or an enum/int that was never assigned and read as 0.","solutions":["Generate a real value (Guid.NewGuid()) or fetch the real id before calling NotDefaultOrNull.","If default(T) is a legal value for your domain, use Check.NotNull on a boxed reference or a different guard instead.","Set sensible non-default initializers on DTO properties (e.g. CreatedAt = Clock.Now).","Reject default(T) at the API boundary so the caller is told the field is effectively unset."],"exampleFix":"// before\nvar id = Check.NotDefaultOrNull(entity.Id, nameof(entity.Id));\n\n// after\nentity.Id = entity.Id == Guid.Empty ? Guid.NewGuid() : entity.Id;\nvar id = Check.NotDefaultOrNull(entity.Id, nameof(entity.Id));","handlingStrategy":"validation","validationCode":"static bool IsNotDefault<T>(T? value) where T : struct\n    => value is not null && !value.Value.Equals(default(T));\n\nif (!IsNotDefault(entity.Id)) return BadRequest(\"Id is empty/default\");","typeGuard":"static bool IsMeaningful(Guid? id) => id is Guid g && g != Guid.Empty;","tryCatchPattern":"try\n{\n    var id = Check.NotDefaultOrNull(entity.Id, nameof(entity.Id));\n}\ncatch (ArgumentException ex) when (ex.ParamName == nameof(entity.Id))\n{\n    return BadRequest(ex.Message);\n}","preventionTips":["Generate Guid.NewGuid() at construction rather than relying on Guid.Empty.","Treat default(struct) as 'unset' in your domain and reject it at the boundary.","If default(T) is legitimate in your domain, do not use NotDefaultOrNull."],"tags":["validation","argument","nullable","default-value","check","abp-core"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}