lgi-devs / lgi-devs/lgi

`GLib.Variant: no 'n'` when using `GLib.Variant("(av)", ...)`

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

Nobody has claimed this yet.

Dominant language
Lua
Stars
491
Forks
81
PR merge metrics
No merged PRs in 30d

Description

I get the following error:

2024-01-23 23:28:50 E: awesome: Error during a protected call: /usr/share/lua/5.4/lgi/override/GLib-Variant.lua:141: GLib.Variant: no 'n'
stack traceback:
	[C]: in function 'error'
	/usr/share/lua/5.4/lgi/component.lua:160: in function </usr/share/lua/5.4/lgi/component.lua:156>
	[C]: in metamethod 'index'
	/usr/share/lua/5.4/lgi/override/GLib-Variant.lua:141: in upvalue 'variant_new'
	/usr/share/lua/5.4/lgi/override/GLib-Variant.lua:159: in upvalue 'variant_new'
	/usr/share/lua/5.4/lgi/override/GLib-Variant.lua:176: in function </usr/share/lua/5.4/lgi/override/GLib-Variant.lua:170>
	(...tail calls...)
	/home/delta/.config/awesome/curious.lua:87: in function </home/delta/.config/awesome/curious.lua:81>
	[C]: in function 'xpcall'
	/usr/share/awesome/lib/gears/protected_call.lua:41: in function </usr/share/awesome/lib/gears/protected_call.lua:40>
	(...tail calls...)
	/home/delta/.config/awesome/curious.lua:92: in upvalue 'target'
	/usr/share/lua/5.4/lgi/override/GObject-Closure.lua:286: in function </usr/share/lua/5.4/lgi/override/GObject-Closure.lua:283>

When using this piece of code:

-- ...
local builder = GLib.VariantBuilder(GLib.VariantType("av"))
serialize(builder, { "test", some_key = "some_value" }) -- constructs a fully valid variant array
invocation:return_value(GLib.Variant("(av)", { builder }))
-- ...

(Sidenote: It seems that even if it didn't fail, it would be inefficient as for some reason the variant_new function doesn't make the distinction between a lua table and a Variant)

Contributor guide

No contributing guide indexed for this repository

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 in lgi/override/GLib-Variant.lua at lines 141-143 and reproduce the failure with GLib.Variant("(av)", { builder }) from the issue. Investigate how variant_new handles the VariantBuilder argument; done means this valid variant-array construction no longer raises "GLib.Variant: no 'n'".

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.