Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0853a0c
fix: Skip media entities with empty URI from GEDCOM OBJE without FILE
isaacschepp Mar 31, 2026
144dd5c
fix: Clean up stale MediaIDMap entry and strengthen empty-URI test
isaacschepp Mar 31, 2026
f4e143c
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Mar 31, 2026
103103d
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
fb99c50
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
4ff0b15
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
f5eb0c1
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
f7294e8
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
7abe39a
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
e2b6e30
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
f63b39a
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 1, 2026
77339ee
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
c732f0c
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
ecd30fa
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
2c35ccd
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
a76e8e3
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
c5984ea
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
a5c37d9
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
3db11a4
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
9844224
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
9823c28
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
cea825c
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
775b410
Merge main into fix/empty-media-uri
genealogix-ci-bot[bot] Apr 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions go-glx/gedcom_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,44 @@ func TestImportCensus_WithMedia(t *testing.T) {
assert.True(t, mediaLinked, "census OBJE should be linked to source or citation")
}

// TestImportMedia_EmptyFileSkipped tests that OBJE records with empty FILE
// values do not create media entities with empty URIs. Fixes #492.
func TestImportMedia_EmptyFileSkipped(t *testing.T) {
gedcom := `0 HEAD
1 GEDC
2 VERS 5.5.1
0 @O1@ OBJE
1 FILE
1 TITL Empty file reference
0 @I1@ INDI
1 NAME Test /Person/
0 TRLR`

glxFile, _, err := ImportGEDCOM(strings.NewReader(gedcom), nil)
require.NoError(t, err)

// Should NOT create a media entity with empty URI — the OBJE should be skipped entirely
assert.Empty(t, glxFile.Media, "OBJE with empty FILE should not create any media entity")
}

// TestImportMedia_NoFileTagSkipped tests that OBJE records with no FILE tag
// at all do not create media entities.
func TestImportMedia_NoFileTagSkipped(t *testing.T) {
gedcom := `0 HEAD
1 GEDC
2 VERS 5.5.1
0 @O1@ OBJE
1 TITL Photo with no file reference
0 @I1@ INDI
1 NAME Test /Person/
0 TRLR`

glxFile, _, err := ImportGEDCOM(strings.NewReader(gedcom), nil)
require.NoError(t, err)

assert.Empty(t, glxFile.Media, "OBJE with no FILE tag should not create a media entity")
}

// TestImportFamilyCensus_SingleSpouse tests family census with only one spouse.
func TestImportFamilyCensus_SingleSpouse(t *testing.T) {
gedcom := `0 HEAD
Expand Down
14 changes: 14 additions & 0 deletions go-glx/gedcom_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ func convertMedia(objeRecord *GEDCOMRecord, conv *ConversionContext) error {
// Convert using common logic
media := convertMediaCommon(objeRecord, mediaID, conv)

// Skip media entities with empty URI — happens when OBJE has no FILE
// tag or an empty FILE value and no BLOB data. Fixes #492.
if media.URI == "" {
conv.Logger.LogInfof("Skipping OBJE %s: no FILE reference or BLOB data", objeRecord.XRef)
delete(conv.MediaIDMap, objeRecord.XRef) // clean up stale mapping
return nil
}

// Handle SOUR subrecords (only for top-level OBJE records)
for _, sub := range objeRecord.SubRecords {
if sub.Tag == GedcomTagSour {
Expand Down Expand Up @@ -76,6 +84,12 @@ func convertEmbeddedMedia(objeRecord *GEDCOMRecord, conv *ConversionContext) str
// Convert using common logic
media := convertMediaCommon(objeRecord, mediaID, conv)

// Skip if no URI (empty FILE, no BLOB). Fixes #492.
if media.URI == "" {
conv.Logger.LogInfo("Skipping embedded OBJE: no FILE reference or BLOB data")
return ""
}

// Store media
conv.GLX.Media[mediaID] = media
conv.Stats.MediaCreated++
Expand Down
Loading