Issue with OR and complex query

I'm having an issue with a complex ability:
  # ability.rb
  can :read, Document, :document_lenders => { :lender_id => user.lender_id }
  can :read, Document, :document_lender_groups => { :lender_group_id => user.lender.lender_group_ids }

According to the docs (https://github.com/CanCanCommunity/cancancan/wiki/defining-abilities#combining-abilities), I would imagine these two would work together to form an "OR". Perhaps they're too complex? The statements work well individually, but not together.
Here's the error I'm receiving - notice at the end of the SQL statement where the Ruby hash is injected and not turned into SQL:
PG::SyntaxError: ERROR:  syntax error at or near "{"
LINE 1: ..."loans"."id" = "document_loans"."loan_id" WHERE (({:document...
                                                             ^
: SELECT "documents"."id" AS t0_r0, "documents"."title" AS t0_r1, "documents"."file_file_name" AS t0_r2, "documents"."file_content_type" AS t0_r3, "documents"."file_file_size" AS t0_r4, "documents"."file_updated_at" AS t0_r5, "documents"."report_type" AS t0_r6, "documents"."created_at" AS t0_r7, "documents"."updated_at" AS t0_r8, "documents"."guid" AS t0_r9, "document_lenders"."id" AS t1_r0, "document_lenders"."document_id" AS t1_r1, "document_lenders"."lender_id" AS t1_r2, "document_lenders"."created_at" AS t1_r3, "document_lenders"."updated_at" AS t1_r4, "lenders"."id" AS t2_r0, "lenders"."name" AS t2_r1, "lenders"."short_name" AS t2_r2, "lenders"."created_at" AS t2_r3, "lenders"."updated_at" AS t2_r4, "document_lender_groups"."id" AS t3_r0, "document_lender_groups"."lender_group_id" AS t3_r1, "document_lender_groups"."document_id" AS t3_r2, "document_lender_groups"."created_at" AS t3_r3, "document_lender_groups"."updated_at" AS t3_r4, "lender_groups"."id" AS t4_r0, "lender_groups"."name" AS t4_r1, "lender_groups"."created_at" AS t4_r2, "lender_groups"."updated_at" AS t4_r3, "document_loans"."id" AS t5_r0, "document_loans"."document_id" AS t5_r1, "document_loans"."loan_id" AS t5_r2, "document_loans"."created_at" AS t5_r3, "document_loans"."updated_at" AS t5_r4, "loans"."id" AS t6_r0, "loans"."loan_type" AS t6_r1, "loans"."borrower_name" AS t6_r2, "loans"."borrower_type" AS t6_r3, "loans"."property_address" AS t6_r4, "loans"."user_id" AS t6_r5, "loans"."expiration_date" AS t6_r6, "loans"."photo_file_name" AS t6_r7, "loans"."photo_content_type" AS t6_r8, "loans"."photo_file_size" AS t6_r9, "loans"."photo_updated_at" AS t6_r10, "loans"."status" AS t6_r11, "loans"."loan_overview" AS t6_r12, "loans"."summary" AS t6_r13, "loans"."posted_date" AS t6_r14, "loans"."loan_amount" AS t6_r15, "loans"."amount_available" AS t6_r16, "loans"."guarantors" AS t6_r17, "loans"."appraised_value" AS t6_r18, "loans"."proposed_interest_rate" AS t6_r19, "loans"."current_interest_rate" AS t6_r20, "loans"."ltv" AS t6_r21, "loans"."dscr" AS t6_r22, "loans"."required_dscr" AS t6_r23, "loans"."risk_rating" AS t6_r24, "loans"."collateral" AS t6_r25, "loans"."term" AS t6_r26, "loans"."amort" AS t6_r27, "loans"."notes" AS t6_r28, "loans"."mbc_users_to_notify" AS t6_r29, "loans"."created_at" AS t6_r30, "loans"."updated_at" AS t6_r31, "loans"."guid" AS t6_r32, "loans"."type_of_opportunity" AS t6_r33, "loans"."associated_lenders" AS t6_r34, "loans"."associated_lender_groups" AS t6_r35 FROM "documents" LEFT OUTER JOIN "document_lenders" ON "document_lenders"."document_id" = "documents"."id" LEFT OUTER JOIN "lenders" ON "lenders"."id" = "document_lenders"."lender_id" LEFT OUTER JOIN "document_lender_groups" ON "document_lender_groups"."document_id" = "documents"."id" LEFT OUTER JOIN "lender_groups" ON "lender_groups"."id" = "document_lender_groups"."lender_group_id" LEFT OUTER JOIN "document_loans" ON "document_loans"."document_id" = "documents"."id" LEFT OUTER JOIN "loans" ON "loans"."id" = "document_loans"."loan_id" WHERE (({:document_lender_groups=>{:lender_group_id=>[1]}}) OR ({:document_lenders=>{:lender_id=>1}}))

Here's the basics of my model setup:
class User
  belongs_to :lender
end

class Lender
  has_many :lender_groups
end

class LenderGroup
  has_many :lender_group_lenders
  has_many :lenders, through: :lender_group_lenders
end

class Document
  has_many :document_lenders
  has_many :document_lender_groups
  has_many :lenders, through: :document_lenders
  has_many :lender_groups, through: :document_lender_groups
end

class DocumentLender
  belongs_to :lender
  belongs_to :documents
end

Is it possible that this is an error? I can find some workarounds, but it would be great if this would work. Noticing the ruby at the end of the SQL statement leads me to believe that something isn't translating the ability into a SQL statement correctly - but I'm not sure.
Thanks!

Any hopes on getting this fixed?

approve, I have the similar issue =|
Rails 5.0.0.beta3
but same construction is still working nice with Rails <IP_ADDRESS>

actually the basic problem is because active record changed its api in v5.0.0.beta2
https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/sanitization.rb#L22
https://github.com/rails/rails/blob/v5.0.0.beta2/activerecord/lib/active_record/sanitization.rb#L32
@hallmatt simple workaround that helped me - try to use strings instead of symbols like
  can :read, Document, 'document_lenders' => { 'lender_id' => user.lender_id }
  can :read, Document, 'document_lender_groups' => { 'lender_group_id' => user.lender.lender_group_ids }

cancancan (1.14.0) + postgres 9.5.3
can :read, Pie, is_tasty: true, jam_id: nil

produces SQL
SELECT "pies".*  I'll give it a shot.

@hallmatt np, but please note that this is a workaround and it's not reliable. For example it does not work for checking abilities on instance...
I have ended up with writing abilities in that way that they do not require OR.

@rilian @hallmatt my solution is just use can :read, Entity, id: Entity.where(conditions).pluck(:id)
looks like it works god

@hallmatt Are you still having this issue on Rails 5? I'm unable to reproduce it on Rails 5.0.0 with CanCanCan version 1.14.0 or 1.15.0 and PostgreSQL 9.5.4. When I set up the models as you have and run ability.model_adapter(Document, :index).conditions I get:
"(\"document_lender_groups\".\"lender_group_id\" IN (1, 2, 3)) OR (\"document_lenders\".\"lender_id\" = 1)"

Which looks right to me...

@alexsanford I was still having the issue. I ended up solving it a different way - so it's not as pressing for me anymore.

I was experiencing the same issue locally with Rails <IP_ADDRESS>, CanCanCan 1.14.0, and PG 9.5.2.  Upgrading to CanCanCan 1.15.0 resolved the issue for me.

seems a duplicate of https://github.com/CanCanCommunity/cancancan/issues/410. I close this issue, feel free to reopen in case the problem persists. Thanks


memory leak in android kitkat

i have a memory leak when i load a file around 500kb to rhino in android kitkat
do you have tested rhino with big files in android kitkat?

No, I haven't tested this in any bigger scale. I currently know of one app which will use this in a beta release with several thousand users soon (probably next week). Until then I don't really have access to testers.
If you can provide additional data, like a logcat and the js file used I will try to reproduce and investigate the issue.

Closing as no more info was provided.


JsonRpcServer does not return a proper class instance but only an object with its properties

This caused an issue here when running e2e_aztec_js_browser.test.ts.

@benesjan Can you give more information around this one please? What was the problem you faced? Do we need to do this before the sandbox is released?

@PhilWindle the issue doesn't seem to occur anymore so I re-enabled the check in this PR and we can close this issue.


MB-14216: Adds SC weight ticket review integration test

Jira ticket for this change
Summary
This pull request creates an integration test around the service counselor review of PPM weight tickets, verifying that a service counselor can review, approve/reject, and edit weight tickets submitted by a customer.
The code in this pull request uses some different techniques than the code in service counselor integration tests which were semi-automatically ported over from the Cypress equivalent. (For example, compare navigateToCloseoutMove with the existing navigateToMove functions in servicesCounselingTestFixture.js.) A future pull request will refactor the ported code to use these techniques.
Setup to Run Your Code
This integration test should run on CircleCI (in the integration_tests step).
If you'd like to run it locally as well, you'll need both the server (make server_run) and client (make office_client_run) in separate terminal windows; then,
npx playwright test playwright/tests/office/servicescounseling/servicesCounselingWeightTickets.spec.js  --trace="on"

Verification Steps for Author
These are to be checked by the author.

[ ] Request review from a member of a different team.
[ ] Have the Jira acceptance criteria been met for this change?

Messages

:book:
:link: MB-14216

  Generated by :no_entry_sign: dangerJS against 9ea98b471ca6ac6546977e74bcdb44fce261dcf1

I was able to successfully run the test locally! One note in case others forget like I did, you'll need the server and client running locally before you can run the playwright test(s) successfully. Otherwise you'll just get a timeout error 😅

As an oh by the way, the run-e2e-test script runs all the tests by default, but you can pass in options to only run certain ones.
./scripts/run-e2e-test --trace=on playwright/tests/office/servicescounseling/servicesCounselingWeightTickets.spec.js


Loading BDF files fails

The last commit that affected mne/io/edf/edf.py (https://github.com/mne-tools/mne-python/commit/9ac6547284bbd73b4c18d7d7031042585388005c#diff-825d45683d0be02fad23614151867e02) broke it. When I load a BDF file like this, I get an error:
raw = mne.io.read_raw_edf("test.bdf")

Traceback (most recent call last):
  File "/Users/clemens/Library/Preferences/PyCharmCE2017.2/scratches/scratch_4.py", line 4, in <module>
    raw = mne.io.read_raw_edf("/Volumes/Begabungsforschung/Analysis/Data/EEG/adds/vp1/vp1_exp_eeg.bdf")
  File "/Users/clemens/Repositories/adds/mne/io/edf/edf.py", line 1229, in read_raw_edf
    exclude=exclude, preload=preload, verbose=verbose)
  File "<string>", line 2, in __init__
  File "/Users/clemens/Repositories/adds/mne/utils.py", line 728, in verbose
    return function(*args, **kwargs)
  File "/Users/clemens/Repositories/adds/mne/io/edf/edf.py", line 158, in __init__
    annotmap, eog, misc, exclude, preload)
  File "/Users/clemens/Repositories/adds/mne/io/edf/edf.py", line 564, in _get_info
    tal_channel is None and n_samps[stim_channel] != int(max_samp):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

However, if I set stim_channel='auto' explicitly, it works. This is strange since this is also the default value.

So this is almost certainly related to the same commit/PR as #4710, but is now a new breakage mode?
It looks like these are documented clearly enough that we should be able to fix it. I can try to find time to fix it in the next week or so unless someone else beats me to it. We'll need to fix and backport to 0.15.

So this is almost certainly related to the same commit/PR as #4710, but is now a new breakage mode?

This error was introduced by 9ac6547. I don't understand why it occurs yet, because explicitly setting stim_channel='auto' should be the same as using the default - but it's not.
No need to backport, this commit was after 0.15.

It is different in the reader read_raw_edf:
https://github.com/mne-tools/mne-python/blob/master/mne/io/edf/edf.py#L1154
Than in the class RawEDF:
https://github.com/mne-tools/mne-python/blob/master/mne/io/edf/edf.py#L153
Can you make a quick PR to fix it? If not I can get to it later this week.

Alright, this should be fixed in #4751


[BUG] fix FeatureUnion test failure mk2

This fixes #1662 which PR #1665 did not fix.
That #1665 did not fix #1662 was not detected due to faulty remote CI and, I guess, @TonyBagnall not checking locally.
Note: the remote CI fault is being fixed in #1695 but this is not merged yet so the same problem could happen again.
The fix in thie PR replaces inheritance in FeatureUnion by the wrapper pattern.
That fixes the bug #1662, since it was caused by FeatureUnion having side effects on constructor arguments which were expected to remain unchanged. The side effects were coming from the package external parent class, so the only simple way to avoid this seems to wrap it and clone the arguments before passing them.
The original arguments don't get changed, since the side effects apply to the cloned versions only.

FYI @lmmentel, @mloning, @TonyBagnall, I think this finally fixes it...

ok, but now other stuff seems to be failing...

closing in favour of #1810


Index out of bounds when printing JSON of ProcessState

I made the minidump_processor fuzzer look more like
let val: Result<_, _> = minidump_processor_fuzz::fuzzing_block_on(
    minidump_processor::process_minidump(&dump, &provider),
);

if let Ok(v) = val {
    v.print_json(&mut std::io::sink(), true);
}

And then found this:
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/jess/src/rust-minidump/minidump-processor/src/process_state.rs:806:45
stack backtrace:
   0: rust_begin_unwind
             at /rustc/88fb06a1f331926bccb448acdb52966fd1ec8a92/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/88fb06a1f331926bccb448acdb52966fd1ec8a92/library/core/src/panicking.rs:135:14
   2: core::panicking::panic_bounds_check
             at /rustc/88fb06a1f331926bccb448acdb52966fd1ec8a92/library/core/src/panicking.rs:77:5
   3: minidump_processor::process_state::ProcessState::print_json
   4: rust_fuzzer_test_input
   5: LLVMFuzzerTestOneInput
   6: _ZN6fuzzer6Fuzzer15ExecuteCallbackEPKhm
   7: _ZN6fuzzer10RunOneTestEPNS_6FuzzerEPKcm
   8: _ZN6fuzzer12FuzzerDriverEPiPPPcPFiPKhmE
   9: main
  10: __libc_start_main
  11: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
==3765619== ERROR: libFuzzer: deadly signal
NOTE: libFuzzer has rudimentary signal handlers.
      Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal

json-crash.zip

Ah yeah, we do some raw indexing with requesting_thread here:
https://github.com/luser/rust-minidump/blob/8e1f9a8f9fb67d25a817b48fdee7b9870e1cb321/minidump-processor/src/process_state.rs#L806
I'd need to think about the testcase and code more to have a strong opinion on whether this code should just be more careful or if the processor should be producing more reasonable output.

IMO the processor should be generating output in a such a way that will never cause a print to fail like this
we also have integer overflows in the printer, and if we don't know ahead of time which are valid/invalid, we'll need to deal with "oh we wrote half a dump and then failed.... what now?" Unless there's a mechanism in the format to say "this value is invalid but we continued on" or whatever. This was the human readable printer, but there also looks to be one in the json printer, see:
https://github.com/luser/rust-minidump/blob/8e1f9a8f9fb67d25a817b48fdee7b9870e1cb321/minidump-processor/src/process_state.rs#L785


Aligned 3d Face model with the detected face landmarks (3d points)

Is there anyone who implemented or added a face model like glasses or Mask to the detected 3d face landmarks? or if anyone can point to a link or thread where we can study about implementing it ourselves?
thank you

related to #79

@homuler as you mention that Packet class is not implemented yet and you planned to implement a sample soon. is there anything done related to it?

I implemented Packet<Mesh3d> class once in a working branch, but did not merge it to the master branch because I found it unnecessary.
After all, if you don't create a Mesh in Unity, it's not useful.

or if anyone can point to a link or thread where we can study about implementing it ourselves?

https://github.com/keijiro/FaceMeshBarracuda
https://github.com/keijiro/FaceLandmarkBarracuda/blob/0ff22f2ecbd2d73e8e04bb7dc3bd1649f5942ae7/Assets/Editor/TemplateBuilder.cs
By the way, is it same as #79?
If so, I'd like to close this.

Thank you. I will have a look at the FaceMeshBarracude.
I was actually trying to add some overlay filters models like ears and nose or glasses.
https://developers.google.com/ar/develop/augmented-faces.
i am not sure if creating a Mesh will help me with it.

Closing because it's same as #79


fixed #251

Whoops, forgot to configure my username on a new git install.

BTW in the future you'll want to do these changes in a branch instead of in your master branch. I'm going to merge these in but using a rebase which will confuse git if you try to pull in the upstream changes. so I would recommend resetting to before you made these commits, then pulling upstream

merged into my master branch, thanks!


Fix: No navigation object in state picker story

Details

@react-navigation is not imported in storybook causes state picker story throwing error Couldn't find a navigation object. This PR fixes that.
Fixed Issues

$ https://github.com/Expensify/App/issues/38331
PROPOSAL: https://github.com/Expensify/App/issues/38331#issuecomment-2005712632
Tests

[Web only]

Run and open storybook npm run storybook (port 6006)
Go to Form >> Default
Select any date and year in Date of Birth field
Verify date is selected
Press State field
Verify state picker opens

[x] Verify that no errors appear in the JS console

Offline tests

NA
QA Steps

[Web only]

Go to /docs/index.html
Go to Form >> Default
Select any date and year in Date of Birth field
Verify date is selected
Press State field
Verify state picker opens

[x] Verify that no errors appear in the JS console

PR Author Checklist

[x] I linked the correct issue in the ### Fixed Issues section above
[x] I wrote clear testing steps that cover the changes made in this PR

[x] I added steps for local testing in the Tests section
[x] I added steps for the expected offline behavior in the Offline steps section
[x] I added steps for Staging and/or Production testing in the QA steps section
[x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
[x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
[x] I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).

[x] I included screenshots or videos for tests on all platforms
[x] I ran the tests on all platforms & verified they passed on:

[x] Android: Native
[x] Android: mWeb Chrome
[x] iOS: Native
[x] iOS: mWeb Safari
[x] MacOS: Chrome / Safari
[x] MacOS: Desktop

[x] I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
[x] I followed proper code patterns (see Reviewing the code)

[x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
[x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
[x] I verified that comments were added to code that is not self explanatory
[x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
[x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method

[x] If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:

[x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
[x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
[x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
[x] I verified the JSDocs style guidelines (in STYLE.md) were followed

[x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
[x] I followed the guidelines as stated in the Review Guidelines
[x] I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
[x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
[x] I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
[x] I verified that if a function's arguments changed that all usages have also been updated correctly
[x] If any new file was added I verified that:

[x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory

[x] If a new CSS style is added I verified that:

[x] A similar style doesn't already exist
[x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))

[x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
[x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
[x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
[x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
[x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:

[x] I verified that all the inputs inside a form are aligned with each other.
[x] I added Design label and/or tagged @Expensify/design so the design team can review the changes.

[x] If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
[x] If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: mWeb Chrome

https://github.com/Expensify/App/assets/113963320/ee0eedc3-b6fb-414f-a7ba-454259c60406

iOS: mWeb Safari

https://github.com/Expensify/App/assets/113963320/bcc26c8b-9b45-4cb0-bb40-9bfe9af3d9bb

MacOS: Chrome / Safari

https://github.com/Expensify/App/assets/113963320/c913f300-170f-42f2-919f-354601d7e385

:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.


Pre-trained model

Could you share any pre-trained model?
There is a model in Python2 branch, but I got irrelevant results like

Is there any other trained model ?

HI Emre, I don't have access to the weights anymore. Sorry! It might be helpful to look for some more updated models as well as the dataset has had some significant changes, since I worked on it.