Skip to content

feat: add http headers parameter to cli and local app#2162

Open
davidgamez wants to merge 3 commits into
masterfrom
custom_user_agent
Open

feat: add http headers parameter to cli and local app#2162
davidgamez wants to merge 3 commits into
masterfrom
custom_user_agent

Conversation

@davidgamez
Copy link
Copy Markdown
Member

@davidgamez davidgamez commented May 13, 2026

Summary:

Closes: #2138
This PR adds support for custom HTTP headers. The custom HTTP headers are only present in the feed download request. The changes include CLI and local App support; Out of scope: web/API support for custom headers.
This can be tested locally:

java -jar ./cli/build/libs/gtfs-validator-0.1.0-SNAPSHOT-cli.jar --url https://apis.metroinfo.co.nz/rti/gtfs/v1/gtfs.zip --stdout --http_header "Ocp-Apim-Subscription-Key: YOUR KEY HERE"

App changes:
Screenshot 2026-05-13 at 11 07 28 AM

From our AI friend

This pull request adds support for specifying custom HTTP headers when downloading GTFS feeds, both in the GUI and CLI. It introduces a multi-line text field in the GUI for headers, validates the input format, ensures headers are not persisted for security, and updates the CLI to support repeated --http_header arguments. Comprehensive tests are included to verify correct parsing, validation, and security behavior.

GUI enhancements:

  • Added a multi-line JTextArea for custom HTTP headers in the advanced options panel of the GUI (GtfsValidatorApp.java). This includes input validation, error display, and disables the Validate button if the headers are invalid. Headers are parsed and attached to the validation config when running. ([[1]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR84-R85), [[2]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR310-R337), [[3]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR389-R395), [[4]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR406-R408), [[5]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR456-R497), [6]

  • Added new methods to get/set HTTP headers in GtfsValidatorApp, and ensured the text is stripped for input fields. ([[1]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR137-R147), [[2]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aL376-R430), [[3]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aL386-R440))

Security improvements:

  • Updated GtfsValidatorPreferences so that HTTP headers are never persisted between sessions, preventing accidental credential leaks. ([[1]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-894cc05fe01e8f1e52dc74d7340a0358bdd7c8b322aeb13cc6dc8e905cdd955dR18), [[2]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-894cc05fe01e8f1e52dc74d7340a0358bdd7c8b322aeb13cc6dc8e905cdd955dR31-R41))

CLI enhancements:

  • Added support for multiple --http_header arguments to the CLI, with validation and parsing logic to ensure correct format and inclusion in the validation config. ([[1]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-22608f7bb87b67e77e85dac973612a22a56a222bac933221964362f9bd14c397R20-R28), [[2]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-22608f7bb87b67e77e85dac973612a22a56a222bac933221964362f9bd14c397R120-R127), [[3]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-22608f7bb87b67e77e85dac973612a22a56a222bac933221964362f9bd14c397R163-R176), [[4]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-22608f7bb87b67e77e85dac973612a22a56a222bac933221964362f9bd14c397R237-R244))

Dependency updates:

  • Added Guava as a dependency for immutable collections in the GUI project. ([[1]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-8bd2117f4359f8d33aa1e1e7f848b5c560e87e4893ab60f33e346754af397470R28), [[2]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-ae112f27bed85c17615136da6c93e309513cd176c91961233ae845ad15abb27aR18), [[3]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-3eb8597d612f3d3fa4b3d73e7ec0834c4e74c6a5f85e0f4f9f9c947c788245e2R7), [[4]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-75dac53269f1932f673cd90f34757b8df1138413a3f227f890833d37313627a4R25))

Testing:

  • Added comprehensive tests for HTTP header parsing, validation, config integration, and security (non-persistence) in both GUI and CLI test suites. ([[1]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-3eb8597d612f3d3fa4b3d73e7ec0834c4e74c6a5f85e0f4f9f9c947c788245e2R105-R193), [[2]](https://github.com/MobilityData/gtfs-validator/pull/2162/files#diff-718ef9d6774ef19503af1607cd078479c581350d7a736a9fdf8ce82305614512R59-R80))

These changes collectively improve flexibility for authenticated/authorized downloads, ensure user credentials are not leaked, and maintain robust input validation.

Expected behavior:

The CLI accepts the --http_header parameter to override the default values. The local app's advanced section contains the HTTP headers section

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

config.setStdoutOutput(false);

String gtfsInput = gtfsInputField.getText();
String gtfsInput = gtfsInputField.getText().strip();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite related to the PR's main purpose. However, this fixes a critical error when the URL contains extra spaces.

}

String outputDirectory = outputDirectoryField.getText();
String outputDirectory = outputDirectoryField.getText().strip();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite related to the PR's main purpose. However, this fixes a critical error when the output directory contains extra spaces.

@davidgamez davidgamez marked this pull request as ready for review May 13, 2026 16:25
@github-actions
Copy link
Copy Markdown
Contributor

📝 Acceptance Test Report

📋 Summary

✅ The rule acceptance has passed for commit 7c955ff
Download the full acceptance test report here (report will disappear after 90 days).

📊 Notices Comparison

New Errors (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Errors (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

New Warnings (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Warnings (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

New Info Notices (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Info Notices (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

🛡️ Corruption Check

2 out of 1003 sources (~0 %) are corrupted.
Dataset Ref Report Exists Ref Report Readable Latest Report Exists Latest Report Readable
mdb-1114
mdb-1123
🔍 System errors for mdb-1114 (reference)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1114 (latest)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1123 (reference)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1123 (latest)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]

💾 Out of Memory Check

No datasets experienced an OutOfMemoryError.

⏱️ Performance Assessment

📈 Validation Time

Assess the performance in terms of seconds taken for the validation process.

Time Metric Dataset ID Reference (s) Latest (s) Difference (s)
Average -- 5.65 5.91 ⬆️+0.26
Median -- 1.63 1.83 ⬆️+0.20
Standard Deviation -- 24.09 25.39 ⬆️+1.30
Minimum in References Reports mdb-1788 0.46 0.52 ⬆️+0.06
Maximum in Reference Reports mdb-2014 679.01 723.44 ⬆️+44.44
Minimum in Latest Reports mdb-1817 0.48 0.51 ⬆️+0.03
Maximum in Latest Reports mdb-2014 679.01 723.44 ⬆️+44.44
📜 Memory Consumption
Metric Dataset ID Reference (s) Latest (s) Difference (s)
Average -- 557.85 MiB 583.16 MiB ⬆️+25.31 MiB
Median -- 323.93 MiB 327.93 MiB ⬆️+4.00 MiB
Standard Deviation -- 1007.48 MiB 1.03 GiB ⬆️+44.30 MiB
Minimum in References Reports mdb-25 40.05 MiB 44.79 MiB ⬆️+4.74 MiB
Maximum in Reference Reports mdb-2393 10.15 GiB 10.17 GiB ⬆️+24.64 MiB
Minimum in Latest Reports mdb-68 415.93 MiB 39.43 MiB ⬇️-376.50 MiB
Maximum in Latest Reports mdb-2393 10.15 GiB 10.17 GiB ⬆️+24.64 MiB

@github-actions
Copy link
Copy Markdown
Contributor

📝 Acceptance Test Report

📋 Summary

✅ The rule acceptance has passed for commit 71a93ee
Download the full acceptance test report here (report will disappear after 90 days).

📊 Notices Comparison

New Errors (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Errors (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

New Warnings (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Warnings (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

New Info Notices (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Info Notices (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

🛡️ Corruption Check

2 out of 1003 sources (~0 %) are corrupted.
Dataset Ref Report Exists Ref Report Readable Latest Report Exists Latest Report Readable
mdb-1114
mdb-1123
🔍 System errors for mdb-1114 (reference)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1114 (latest)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1123 (reference)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1123 (latest)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]

💾 Out of Memory Check

No datasets experienced an OutOfMemoryError.

⏱️ Performance Assessment

📈 Validation Time

Assess the performance in terms of seconds taken for the validation process.

Time Metric Dataset ID Reference (s) Latest (s) Difference (s)
Average -- 5.61 5.86 ⬆️+0.25
Median -- 1.67 1.90 ⬆️+0.23
Standard Deviation -- 21.58 22.43 ⬆️+0.84
Minimum in References Reports mdb-2360 0.46 0.58 ⬆️+0.12
Maximum in Reference Reports mdb-2014 582.51 614.75 ⬆️+32.24
Minimum in Latest Reports mdb-1251 0.51 0.54 ⬆️+0.03
Maximum in Latest Reports mdb-2014 582.51 614.75 ⬆️+32.24
📜 Memory Consumption
Metric Dataset ID Reference (s) Latest (s) Difference (s)
Average -- 593.34 MiB 564.80 MiB ⬇️-28.54 MiB
Median -- 323.93 MiB 327.93 MiB ⬆️+4.00 MiB
Standard Deviation -- 1.07 GiB 1009.00 MiB ⬇️-89.34 MiB
Minimum in References Reports mdb-77 39.64 MiB 41.50 MiB ⬆️+1.86 MiB
Maximum in Reference Reports mdb-2393 10.18 GiB 10.16 GiB ⬇️-22.60 MiB
Minimum in Latest Reports mdb-61 411.93 MiB 39.61 MiB ⬇️-372.31 MiB
Maximum in Latest Reports mdb-2393 10.18 GiB 10.16 GiB ⬇️-22.60 MiB

@davidgamez davidgamez requested a review from cka-y May 14, 2026 13:22
@github-actions
Copy link
Copy Markdown
Contributor

📝 Acceptance Test Report

📋 Summary

✅ The rule acceptance has passed for commit 67d2d3d
Download the full acceptance test report here (report will disappear after 90 days).

📊 Notices Comparison

New Errors (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Errors (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

New Warnings (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Warnings (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

New Info Notices (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

Dropped Info Notices (0 out of 1001 datasets, ~0%) ✅

No changes were detected due to the code change.

🛡️ Corruption Check

2 out of 1003 sources (~0 %) are corrupted.
Dataset Ref Report Exists Ref Report Readable Latest Report Exists Latest Report Readable
mdb-1114
mdb-1123
🔍 System errors for mdb-1114 (reference)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1114 (latest)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1123 (reference)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]
🔍 System errors for mdb-1123 (latest)
[
  {
    "code": "i_o_error",
    "severity": "ERROR",
    "totalNotices": 1,
    "sampleNotices": [
      {
        "exception": "java.util.zip.ZipException",
        "message": "Archive is not a ZIP archive"
      }
    ]
  }
]

💾 Out of Memory Check

No datasets experienced an OutOfMemoryError.

⏱️ Performance Assessment

📈 Validation Time

Assess the performance in terms of seconds taken for the validation process.

Time Metric Dataset ID Reference (s) Latest (s) Difference (s)
Average -- 5.51 5.71 ⬆️+0.20
Median -- 1.68 1.94 ⬆️+0.27
Standard Deviation -- 17.87 17.14 ⬇️-0.74
Minimum in References Reports mdb-1818 0.49 2.38 ⬆️+1.89
Maximum in Reference Reports mdb-2014 424.25 396.29 ⬇️-27.96
Minimum in Latest Reports mdb-1788 0.51 0.51 ⬇️-0.00
Maximum in Latest Reports mdb-2014 424.25 396.29 ⬇️-27.96
📜 Memory Consumption
Metric Dataset ID Reference (s) Latest (s) Difference (s)
Average -- 587.18 MiB 572.88 MiB ⬇️-14.30 MiB
Median -- 327.93 MiB 327.93 MiB ⬇️0 bytes
Standard Deviation -- 1.05 GiB 1.02 GiB ⬇️-27.96 MiB
Minimum in References Reports mdb-1833 41.08 MiB 371.93 MiB ⬆️+330.85 MiB
Maximum in Reference Reports mdb-2393 10.51 GiB 10.41 GiB ⬇️-110.45 MiB
Minimum in Latest Reports mdb-79 52.61 MiB 40.03 MiB ⬇️-12.57 MiB
Maximum in Latest Reports mdb-2393 10.51 GiB 10.41 GiB ⬇️-110.45 MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow sending custom user-agent

2 participants