{"record":{"id":"952b5edb29295c87","repo":"SonarSource/sonarqube","slug":"sonar-properties-file-by-default-must-not-provide","errorCode":null,"errorMessage":"sonar.properties file by default must not provide any user configuration.","messagePattern":"sonar\\.properties file by default must not provide any user configuration\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"sonar-application/build.gradle","lineNumber":101,"sourceCode":"    jdbc_mssql 'com.microsoft.sqlserver:mssql-jdbc'\n    jdbc_mssql_entra 'com.microsoft.azure:msal4j'\n    jdbc_postgresql 'org.postgresql:postgresql'\n\n    webapp 'org.sonarsource.sonarqube:webapp-assets'\n\n}\n\n// declare dependencies in configuration bundledPlugin to be packaged in lib/extensions\napply from: 'bundled_plugins.gradle'\n\n//verify if sonar.properties files does not have any external input\ntask verifySonarProperties(type: Verify) {\n  def propertiesFile = file('src/main/assembly/conf/sonar.properties')\n  propertiesFile.withReader { reader ->\n    def line\n    while ((line = reader.readLine()) != null) {\n      if (!line.startsWith('#') && !line.isEmpty()) {\n        throw new GradleException('sonar.properties file by default must not provide any user configuration.')\n      }\n    }\n  }\n}\n\n\ntasks.register('generateLicenseReport', WriteDependencyLicensesTask) {\n  configurationName = 'appLicenses'\n  outputDir = layout.buildDirectory.dir('reports/dependency-license')\n}\n\ntasks.register('downloadJres') {\n  inputs.file(layout.projectDirectory.dir('src/main/resources/jres-metadata.json').asFile).withPathSensitivity(PathSensitivity.RELATIVE)\n  outputs.dir(layout.buildDirectory.file('jres'))\n  outputs.cacheIf { true }\n\n  doFirst {\n    // Clean the output directory before downloading so stale JREs from previous versions don't accumulate.","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-application/build.gradle#L83-L119","documentation":"The verifySonarProperties task checks that the packaged default conf/sonar.properties in sonar-application contains only comments and blank lines. SonarQube ships a clean default config; any uncommented user setting in that source file aborts the build with this GradleException.","triggerScenarios":"Editing src/main/assembly/conf/sonar.properties and adding a non-comment, non-empty line (e.g. uncommenting sonar.jdbc.username=... or sonar.web.port=...), then running a build that depends on verifySonarProperties.","commonSituations":"Developers editing the shipped default file to test configuration instead of their local instance's conf; accidentally uncommenting a line while reading the template; automated scripts rewriting the file.","solutions":["Revert sonar.properties to comments-only: prefix any active setting with '#'","Test configuration on your installed instance's conf/sonar.properties, not the packaged template","If a default must change intentionally, update the verification task/build expectations deliberately, keeping the shipped file commented"],"exampleFix":"// before (sonar.properties)\nsonar.web.port=9001\n// after (sonar.properties)\n#sonar.web.port=9001","handlingStrategy":"validation","validationCode":"// shell: fail fast if shipped sonar.properties has active lines\ngrep -vE '^\\s*(#|$)' sonar-application/src/main/assembly/conf/sonar.properties \\\n  && { echo \"sonar.properties must contain only comments\"; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never uncomment lines in the packaged conf/sonar.properties template","Configure real instances via their own conf/sonar.properties, not the source template","Review diffs to sonar.properties before committing — every line must start with '#' or be empty"],"tags":["gradle","build","configuration","sonarqube"],"backgroundTag":"invalid-config-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}