ARTIFACTORY: How to resolve ‘The content of element 'git' is not complete’ observed in the logs after the Artifactory restart?

ARTIFACTORY: How to resolve ‘The content of element 'git' is not complete’ observed in the logs after the Artifactory restart?

AuthorFullName__c
Vishal Suvarna
articleNumber
000005945
ft:sourceType
Salesforce
FirstPublishedDate
2024-01-02T13:48:07Z
lastModifiedDate
2023-12-26
VersionNumber
1
Symptom:
Upon creating a VCS repository, the application started returning the following error,
2023-07-18T04:03:04.388Z [jfrt ] [ERROR] [6e227321575b86e5] [.CentralConfigServiceImpl:1084] [art-init] - Could not load configuration due to: Failed to read object from stream
java.lang.RuntimeException: Failed to read object from stream
    at org.artifactory.jaxb.JaxbHelper.read(JaxbHelper.java:183)
    at org.artifactory.jaxb.JaxbHelper.readConfig(JaxbHelper.java:93)
...
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'git' is not complete. One of '{"http://artifactory.jfrog.org/xsd/3.1.29":registryUrl}' is expected.

Root Cause:
While creating a VCS repository, if we miss adding the Registry URL, it would load the Config Descriptor with incomplete tags resulting in the initialisation issue. Upon running into this issue, the Config Descriptor file [artifactory.config.latest.xml] would look like,
    <remoteRepository>
            <key>github-com-rust-lang-crates-io-index-remote</key>
            <type>cargo</type>
...
...         <rejectInvalidJars>false</rejectInvalidJars>
            <git/>
            <contentSynchronisation>
 ...
 ...
            <disableUrlNormalization>false</disableUrlNormalization>
        </remoteRepository>

If you notice the git tags, it is incorrect and not complete as well. So, while the system is attempting to parse the XML content at the time of application initialisation, it would fail with the aforementioned error.

Solution:
We could overcome this issue by just correcting the tags and bootstrapping it against the global configuration.

Step 1: Rename the artifactory.config.latest.xml file to artifactory.config.import.xml, which is placed under $JFROG_Home/var/etc/artifactory.

Note: Kindly take a backup of the file before making changes.

Step 2: Add the registry url tag in the concerned repository section, right after the <rejectInvalidJars>false</rejectInvalidJars> tag, as highlighted below.
<remoteRepository>
            <key>github-com-rust-lang-crates-io-index-remote</key>
            <type>cargo</type>
...
...         <rejectInvalidJars>false</rejectInvalidJars>
           <git>
                <registryUrl></registryUrl>
            </git>          
            <contentSynchronisation>
 ...
 ...
            <disableUrlNormalization>false</disableUrlNormalization>
        </remoteRepository>

Step 3: Perform the Artifactory restart for the changes to take effect. The artifactory.config.import.xml file will be renamed to artifactory.config.bootstrap.xml and loaded successfully at the time of application initilisation.

Reference:
Bootstrapping the Config Descriptor documentation