jfrog / artifactory-gradle-plugin

JFrog Gradle plugin for Build Info extraction and Artifactory publishing.
Apache License 2.0
21 stars 15 forks source link

Publishing build info fails with 400 “Could not insert build” when dependency is referenced by a lot of tasks #83

Open StenSoft opened 10 months ago

StenSoft commented 10 months ago

Describe the bug

When a dependency of a module is referenced by a lot of tasks, publishing build info fails with

{
  "errors" : [ {
    "status" : 400,
    "message" : "Could not insert build BuildWrapper(build=Build{…}, buildRepo=artifactory-build-info)"
  } ]
}

The problem is that dependency scopes can get very large, in our case some are over 1200 characters. Artifactory fails to insert such dependencies into the database with

Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(1024)
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.jfrog.storage.JdbcHelper.executeUpdate(JdbcHelper.java:267)
at org.jfrog.storage.JdbcHelper.executeUpdate(JdbcHelper.java:244)
at org.artifactory.storage.db.build.dao.BuildDependenciesDao.createBuildDependency(BuildDependenciesDao.java:60)
at org.artifactory.storage.db.build.dao.BuildDependenciesDao.createBuildDependencies(BuildDependenciesDao.java:54)
at org.artifactory.storage.db.build.service.BuildStoreServiceImpl.insertModules(BuildStoreServiceImpl.java:224)
at org.artifactory.storage.db.build.service.BuildStoreServiceImpl.addBuild(BuildStoreServiceImpl.java:149)

We have Android modules that have multiple product flavours and also unit and instrumented tests. There are 28 tasks (scopes) listed in our build info JSON for some dependencies. Some of the tasks are Android Gradle Plugin's internal tasks prefixed with _agp_internal_.

Some solutions on the side of the Artifactory Gradle Plugin would be:

  1. an option to disable or filter dependency scopes (task names)
  2. an option to disable or filter dependencies, especially third-party ones

Current behavior

Publishing build info fails due to a PSQL exception

Reproduction steps

No response

Expected behavior

Publishing build info succeeds

Artifactory Gradle plugin version

5.1.10

Operating system type and version

Debian Linux 12.2

JFrog Artifactory version

7.68.7

Gradle version

8.3