LinkAce icon indicating copy to clipboard operation
LinkAce copied to clipboard

Can't add URL via API with a list by ID

Open m0nhawk opened this issue 10 months ago • 1 comments

Bug Description

The Array of integers doesn't work for /api/v1/links.

How to reproduce

  1. Create list with id 1 (on new instance).
  2. Submit JSON via API.
{
  "url": "https://duckduckgo.com",
  "lists": [
    1
  ],
  "is_private": true
}
  1. See that the URL doesn't have list.

String or list of strings works, only list of integers doesn't.

Expected behavior

URL has a list.

Logs

No response

Screenshots

No response

LinkAce version

v1.14.1

Setup Method

Docker

Operating System

Linux (Ubuntu, CentOS,...)

Client details

No response

m0nhawk avatar Apr 01 '24 05:04 m0nhawk

I will check this again after upgrading the demo to version 1.14.1, but it's working with version 1.14.0.

curl --request POST \
  --url https://demo.linkace.org/api/v1/links \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer s9anum7ODLsxbMQCr4WnYSahCEZViFEB' \
  --header 'Content-Type: application/json' \
  --data '{
    "url": "https://duckduckgo.com",
    "lists": [
      1
    ],
    "is_private": true
  }'

See https://demo.linkace.org/lists/1 then.

Kovah avatar Apr 30 '24 15:04 Kovah

Tested this with the latest version, looks fine. Could you please retry this with your LinkAce?

Kovah avatar May 02 '24 08:05 Kovah

That's interesting...

I checked the demo, it works there.

After that I tried both simple and advanced Docker setup, with both 1.14.0 and 1.14.1 - and it didn't work for me.

I narrowed it down to this line so far:

https://github.com/Kovah/LinkAce/blob/ccd3f4411afb51c7e1556afb7ce4fbf722082f75/app/Repositories/LinkRepository.php#L208

If I replace it with $newEntry = LinkList::find($entry); - it works, but obviously it won't work for tags now.

I don't know Laravel, so can't really understand how it can work in you Demo deployment vs clean Docker setup (I have deployed separate deployment for testing).

m0nhawk avatar May 02 '24 08:05 m0nhawk

I narrowed it down further:

If there is no tag with the same id as a list - it will fail to add a list.

For example, if list has id 1 and there is a tag with id 1 - it will succeed, but if I remove the tag - it will stop working (adding correct list).

m0nhawk avatar May 02 '24 08:05 m0nhawk

I can reproduce it on demo instance.

I have removed tag with id 3 (maps) and now it fails to add the correct list.

Instead it shows this for this link:

Screenshot from 2024-05-02 03-48-48

m0nhawk avatar May 02 '24 08:05 m0nhawk

Thanks for the find! Indeed the code is simply incorrect. I fixed it and will have a look at other issues. If there's nothing else, a release goes out today.

Kovah avatar May 02 '24 09:05 Kovah

Thank you for fix and release. :+1:

m0nhawk avatar May 02 '24 23:05 m0nhawk