dbeaver/dbeaver · warning · DBException
Data source ID missing in bookmark definition
Error message
Data source ID missing in bookmark definition
What it means
Thrown by BookmarkStorage constructor when parsing a bookmark XML file and the 'data-source' attribute (ATTR_DATA_SOURCE) is null on the root element. NOTE: org.w3c.dom.Element.getAttribute() never returns null — it returns an empty string for absent attributes. This means the null check on line 70 will not fire for a genuinely missing attribute; it would only fire if the attribute value were explicitly set to null via DOM manipulation, making this a latent bug.
Source
Thrown at plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/resources/bookmarks/BookmarkStorage.java:71
public static final String TAG_PATH = "path"; //NON-NLS-1
public static final String TAG_IMAGE = "image"; //NON-NLS-1
public static final String TAG_BOOKMARK = "bookmark"; //NON-NLS-1
private String title;
private String description;
private DBPImage image;
private String dataSourceId;
private List<String> dataSourcePath;
public BookmarkStorage(IFile file, boolean loadImage) throws DBException, CoreException {
this.title = file.getFullPath().removeFileExtension().lastSegment();
try (InputStream contents = file.getContents(true)) {
final Document document = XMLUtils.parseDocument(contents);
final Element root = document.getDocumentElement();
this.title = root.getAttribute(ATTR_TITLE);
this.description = root.getAttribute(ATTR_DESCRIPTION);
this.dataSourceId = root.getAttribute(ATTR_DATA_SOURCE);
if (dataSourceId == null) {
throw new DBException("Data source ID missing in bookmark definition");
}
this.dataSourcePath = new ArrayList<>();
for (Element elem : XMLUtils.getChildElementList(root, TAG_PATH)) {
this.dataSourcePath.add(XMLUtils.getElementBody(elem));
}
if (loadImage) {
Element imgElement = XMLUtils.getChildElement(root, TAG_IMAGE);
if (imgElement != null) {
String imgString = XMLUtils.getElementBody(imgElement);
final byte[] imgBytes = Base64.decode(imgString);
ImageLoader loader = new ImageLoader();
this.image = new DBIconBinary(
dataSourcePath.toString(),
loader.load(new ByteArrayInputStream(imgBytes))[0]);
}
}
} catch (XMLException e) {
throw new DBException("Error reading bookmarks storage", e);
View on GitHub (pinned to 1e5ee1042b)
Solutions
- Ensure bookmark XML files include the data-source attribute: <bookmark data-source="connection-id" ...>
- If maintaining this code, fix the check to also test for empty string: if (dataSourceId == null || dataSourceId.isEmpty())
- Regenerate the bookmark from the DBeaver UI to ensure all required attributes are present
Example fix
// before
if (dataSourceId == null) {
throw new DBException("Data source ID missing in bookmark definition");
}
// after
if (CommonUtils.isEmpty(dataSourceId)) {
throw new DBException("Data source ID missing in bookmark definition");
} Defensive patterns
Strategy: validation
Validate before calling
String dsId = root.getAttribute(ATTR_DATA_SOURCE);
// NOTE: getAttribute returns "" not null for missing attributes — check both
if (dsId == null || dsId.trim().isEmpty()) {
throw new DBException("Data source ID missing in bookmark definition");
} Prevention
- Ensure bookmark XML files always include the data-source attribute
- Fix the null check to also handle empty strings (CommonUtils.isEmpty)
- Regenerate bookmarks from the DBeaver UI rather than editing XML by hand
When it happens
Trigger: root.getAttribute(ATTR_DATA_SOURCE) is checked against null. In practice, a missing data-source attribute yields "" (empty string), not null, so this specific throw is effectively unreachable through normal XML parsing. A bookmark file missing the data-source attribute would silently pass this check with an empty dataSourceId.
Common situations: A bookmark XML file that was hand-edited or produced by a buggy export and is missing the data-source attribute. However, due to the DOM API contract, the null check would not catch this — the bookmark would load with an empty dataSourceId and fail later. This error is theoretically for missing data-source references but the guard is incorrect.
Related errors
- Error reading bookmarks storage
- Cannot find meta file
- Cannot parse meta file
- IO Error reading bookmarks storage
- Can't find project node for '{}'
AI-assisted analysis of dbeaver/dbeaver@1e5ee1042b (2026-08-13).
Data as JSON: /api/errors/c8fb881f8924c3c0.
Report an issue: GitHub.