Skip to content

Conversation

@CJGlitter
Copy link

@CJGlitter CJGlitter commented Feb 1, 2026

Summary

Fixes #32 — OFAC discontinued the pipe-delimited (.pip) files on September 25, 2023, which means the gem has been politely failing to download anything useful for a while now.

I opened issue #32 back when I first hit the Trouble downloading file error, and finally got around to implementing a fix. This PR updates the gem to use the XML format that OFAC still actively maintains:

https://www.treasury.gov/ofac/downloads/sdn.xml

Changes

Core Implementation

  • Use Nokogiri for XML parsing
  • Preserve the same denormalization behavior
  • Keep MySQL bulk import and ActiveRecord fallback paths
  • Add proper HTTPS redirect handling (Treasury likes to redirect)

Test Infrastructure

Updated for Ruby 3.4 / Rails 8 compatibility, because time marches on:

  • Replace deprecated shoulda gem with shoulda-context
  • Fix File.exists?File.exist? (Ruby 3.4 finally got tired of warning us)
  • Update migrations to versioned format
  • Use in-memory SQLite for tests

Documentation

  • Update README with new data source URL
  • Update requirements to Rails 6.0+
  • Add Nokogiri as dependency
  • Add changelog entry in History.txt

Test Results

All 26 tests pass (77 assertions). The existing test assertions were preserved — if it worked before, it still works now, just with XML instead of pipes.

Version

Bumped to 3.1.0 — minor version since the public API is unchanged. That said, if you'd prefer 4.0.0 given that the underlying data source changed entirely, that's a reasonable call too.


Thanks for maintaining this gem! It's been quietly useful to a lot of folks checking names against the SDN list.

OFAC discontinued the pipe-delimited (.pip) files on September 25, 2023.
This updates the gem to download and parse the XML format from:
https://www.treasury.gov/ofac/downloads/sdn.xml

Key changes:
- Use Nokogiri for XML parsing with namespace handling
- Preserve the same denormalization behavior (address x alias records)
- Keep MySQL bulk import and ActiveRecord fallback paths
- Add proper HTTPS redirect handling for downloads

Also updates test infrastructure for Ruby 3.4 and Rails 8:
- shoulda-context instead of deprecated shoulda gem
- Fix File.exists? -> File.exist? deprecation
- Update migrations to versioned format
- Use in-memory SQLite for tests

Fixes kevintyll#32
@CJGlitter CJGlitter marked this pull request as draft February 1, 2026 04:23
@CJGlitter CJGlitter marked this pull request as ready for review February 1, 2026 04:23
Wrap config.assets.debug in respond_to? check to handle cases
where sprockets is not loaded in the dummy app environment.
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.

OFAC has discontinued PIP file, disabling reloading OFAC sdn data

1 participant