logseq / logseq/og

Block ID is unstable when writing content in raw HTML

Open
#35 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
297
Forks
52
PR merge metrics
No merged PRs in 30d

Description

### Search first

- [x] I searched and no similar issues were found

### What Happened?

> This is migrated from [#12323](https://github.com/logseq/logseq/issues/12323). It can be reproduced in logseq-og-1.0.0

I found that for blocks written in raw HTML, their block ID changes every time when reading the graph. for example the following two-page graph:

1. "page 1.md"
```markdown
- markdown
- id:: 6962f273-6224-4018-8bef-0331aa4d0e36
| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
- html
-
id:: 6962f467-6626-4f9b-8830-31728a8d75be


A
B
C




1
2
3


4
5
6


7
8
9



-
```

Please note that I did not write `id:: XXXX` manully. They are generated by logseq.

2. "page 2.md"
```markdown
- markdown
- ((6962f273-6224-4018-8bef-0331aa4d0e36))
- html
- ((6962f467-6626-4f9b-8830-31728a8d75be))
-
```

In `page 2`, I referenced to the blocks in `page 1` and it works fine.
![Image](https://github.com/user-attachments/assets/e93725be-9e55-41ae-a0e5-373be00d972a)

However, when I migerate the whole graph (folder) to another machine, the reference to HTML block breaks.
![Image](https://github.com/user-attachments/assets/bb4cc5fa-25d0-4d48-9360-ca64ccbe13e4)

Returning to `page 1`, I found the block ID is re-generated and is different from the previous one.
![Image](https://github.com/user-attachments/assets/6c24c477-74bb-4cc3-9154-c82172908fe0)

On the original machine, the block ID is valid, so the reference is valid.
![Image](https://github.com/user-attachments/assets/68cc2a97-8be1-4a55-8d1d-b0761f0565a0)

But if I click "Re-index" on the original machine, the block ID is also changed:
![Image](https://github.com/user-attachments/assets/b8d2084f-6ef0-43d0-b836-fe5b0f52fa4c)

Causing the block reference breaks:
![Image](https://github.com/user-attachments/assets/2fdf74ad-9372-4ba9-a615-a1d752a1e1c0)

### Reproduce the Bug

1. write a block with HTML
2. reference that block
3. re-index the graph or migrate it to another machine
4. get broken block reference

### Expected Behavior

I expect block reference is stable no matter what I do with the graph (excluding modifing the reference itself)

### Screenshots

_No response_

### Desktop or Mobile Platform Information

Windows 11, Desktop OG app 1.0.0

### Additional Context

_No response_

### Are you willing to submit a PR? If you know how to fix the bug.

- [ ] I'm willing to submit a PR (Thank you!)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how raw HTML blocks are parsed and assigned IDs during graph re-indexing, then compare that path with ordinary Markdown blocks. Reproduce the issue using the two-page graph and the listed re-index or migration steps; done means the HTML block ID remains unchanged and its reference continues to resolve.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.